@vitemcp/server 1.1.0 → 1.2.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.
@@ -222,6 +222,21 @@ interface OAuthProxyConfig {
222
222
  * https URLs enables CWE-601 open-redirect / authorization-code theft.
223
223
  */
224
224
  allowedRedirectUriPatterns?: string[];
225
+ /**
226
+ * Accept `code_challenge_method=plain` at the authorization endpoint
227
+ * (default: false).
228
+ *
229
+ * RFC 7636 §4.2 requires S256 of any client that can compute a SHA-256
230
+ * digest, and OAuth 2.1 — which the MCP authorization spec builds on — drops
231
+ * `plain` altogether. With `plain` the challenge *is* the verifier, so the
232
+ * value sits in the authorization request, in browser history, and in every
233
+ * proxy log along the way; anyone who reads it there can redeem a stolen
234
+ * authorization code. S256 leaks only a hash.
235
+ *
236
+ * Left as an escape hatch for the rare client that genuinely cannot hash.
237
+ * Enabling it re-advertises `plain` in the authorization server metadata.
238
+ */
239
+ allowPlainPkce?: boolean;
225
240
  /** Authorization code TTL in seconds (default: 300) */
226
241
  authorizationCodeTtl?: number;
227
242
  /** Base URL of this proxy server */
@@ -680,6 +695,17 @@ declare class OAuthProxy {
680
695
  * Start periodic cleanup of expired transactions and codes
681
696
  */
682
697
  private startCleanup;
698
+ /**
699
+ * PKCE challenge methods this proxy accepts, advertised in the authorization
700
+ * server metadata and enforced at /oauth/authorize.
701
+ *
702
+ * S256 only by default. `plain` makes the challenge and the verifier the same
703
+ * value, so the secret needed to redeem an authorization code is exposed
704
+ * everywhere the authorization request is: browser history, referrer headers,
705
+ * proxy logs. RFC 7636 §4.2 requires S256 of any client that can hash, and
706
+ * OAuth 2.1 removes `plain` entirely.
707
+ */
708
+ private supportedCodeChallengeMethods;
683
709
  /**
684
710
  * Atomically claim a token mapping, mirroring `OAuthProxyStateStore`: at most
685
711
  * one caller — across all processes sharing the storage — can receive a given
@@ -222,6 +222,21 @@ interface OAuthProxyConfig {
222
222
  * https URLs enables CWE-601 open-redirect / authorization-code theft.
223
223
  */
224
224
  allowedRedirectUriPatterns?: string[];
225
+ /**
226
+ * Accept `code_challenge_method=plain` at the authorization endpoint
227
+ * (default: false).
228
+ *
229
+ * RFC 7636 §4.2 requires S256 of any client that can compute a SHA-256
230
+ * digest, and OAuth 2.1 — which the MCP authorization spec builds on — drops
231
+ * `plain` altogether. With `plain` the challenge *is* the verifier, so the
232
+ * value sits in the authorization request, in browser history, and in every
233
+ * proxy log along the way; anyone who reads it there can redeem a stolen
234
+ * authorization code. S256 leaks only a hash.
235
+ *
236
+ * Left as an escape hatch for the rare client that genuinely cannot hash.
237
+ * Enabling it re-advertises `plain` in the authorization server metadata.
238
+ */
239
+ allowPlainPkce?: boolean;
225
240
  /** Authorization code TTL in seconds (default: 300) */
226
241
  authorizationCodeTtl?: number;
227
242
  /** Base URL of this proxy server */
@@ -680,6 +695,17 @@ declare class OAuthProxy {
680
695
  * Start periodic cleanup of expired transactions and codes
681
696
  */
682
697
  private startCleanup;
698
+ /**
699
+ * PKCE challenge methods this proxy accepts, advertised in the authorization
700
+ * server metadata and enforced at /oauth/authorize.
701
+ *
702
+ * S256 only by default. `plain` makes the challenge and the verifier the same
703
+ * value, so the secret needed to redeem an authorization code is exposed
704
+ * everywhere the authorization request is: browser history, referrer headers,
705
+ * proxy logs. RFC 7636 §4.2 requires S256 of any client that can hash, and
706
+ * OAuth 2.1 removes `plain` entirely.
707
+ */
708
+ private supportedCodeChallengeMethods;
683
709
  /**
684
710
  * Atomically claim a token mapping, mirroring `OAuthProxyStateStore`: at most
685
711
  * one caller — across all processes sharing the storage — can receive a given
package/dist/ViteMCP.cjs CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkF5UZHHHHcjs = require('./chunk-F5UZHHHH.cjs');
15
+ var _chunkMKS3TXYTcjs = require('./chunk-MKS3TXYT.cjs');
16
16
 
17
17
  // src/ViteMCP.ts
18
18
 
@@ -1136,5 +1136,5 @@ var normalizeToolResult = (result) => {
1136
1136
 
1137
1137
 
1138
1138
 
1139
- exports.AuthProvider = _chunkF5UZHHHHcjs.AuthProvider; exports.AzureProvider = _chunkF5UZHHHHcjs.AzureProvider; exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.GitHubProvider = _chunkF5UZHHHHcjs.GitHubProvider; exports.GoogleProvider = _chunkF5UZHHHHcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkF5UZHHHHcjs.OAuthProvider; exports.OAuthProxy = _chunkF5UZHHHHcjs.OAuthProxy; exports.OAuthProxyError = _chunkF5UZHHHHcjs.OAuthProxyError; exports.ServerState = ServerState; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ViteMCP = ViteMCP; exports.ViteMCPError = ViteMCPError; exports.audioContent = audioContent; exports.delay = _promises3.setTimeout; exports.getAuthSession = _chunkF5UZHHHHcjs.getAuthSession; exports.imageContent = imageContent; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.requireAll = _chunkF5UZHHHHcjs.requireAll; exports.requireAny = _chunkF5UZHHHHcjs.requireAny; exports.requireAuth = _chunkF5UZHHHHcjs.requireAuth; exports.requireRole = _chunkF5UZHHHHcjs.requireRole; exports.requireScopes = _chunkF5UZHHHHcjs.requireScopes;
1139
+ exports.AuthProvider = _chunkMKS3TXYTcjs.AuthProvider; exports.AzureProvider = _chunkMKS3TXYTcjs.AzureProvider; exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.GitHubProvider = _chunkMKS3TXYTcjs.GitHubProvider; exports.GoogleProvider = _chunkMKS3TXYTcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkMKS3TXYTcjs.OAuthProvider; exports.OAuthProxy = _chunkMKS3TXYTcjs.OAuthProxy; exports.OAuthProxyError = _chunkMKS3TXYTcjs.OAuthProxyError; exports.ServerState = ServerState; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ViteMCP = ViteMCP; exports.ViteMCPError = ViteMCPError; exports.audioContent = audioContent; exports.delay = _promises3.setTimeout; exports.getAuthSession = _chunkMKS3TXYTcjs.getAuthSession; exports.imageContent = imageContent; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.requireAll = _chunkMKS3TXYTcjs.requireAll; exports.requireAny = _chunkMKS3TXYTcjs.requireAny; exports.requireAuth = _chunkMKS3TXYTcjs.requireAuth; exports.requireRole = _chunkMKS3TXYTcjs.requireRole; exports.requireScopes = _chunkMKS3TXYTcjs.requireScopes;
1140
1140
  //# sourceMappingURL=ViteMCP.cjs.map
@@ -4,8 +4,8 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { Hono } from 'hono';
5
5
  import { cors } from 'hono/cors';
6
6
  export { setTimeout as delay } from 'timers/promises';
7
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-CQ64Us1B.cjs';
8
- export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-CQ64Us1B.cjs';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-DmfNQge_.cjs';
8
+ export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-DmfNQge_.cjs';
9
9
 
10
10
  declare class DiscoveryDocumentCache {
11
11
  #private;
package/dist/ViteMCP.d.ts CHANGED
@@ -4,8 +4,8 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { Hono } from 'hono';
5
5
  import { cors } from 'hono/cors';
6
6
  export { setTimeout as delay } from 'timers/promises';
7
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-CQ64Us1B.js';
8
- export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-CQ64Us1B.js';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-DmfNQge_.js';
8
+ export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-DmfNQge_.js';
9
9
 
10
10
  declare class DiscoveryDocumentCache {
11
11
  #private;
package/dist/ViteMCP.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  requireAuth,
13
13
  requireRole,
14
14
  requireScopes
15
- } from "./chunk-WYT772UD.js";
15
+ } from "./chunk-GBQHIIQM.js";
16
16
 
17
17
  // src/ViteMCP.ts
18
18
  import {
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunkF5UZHHHHcjs = require('../chunk-F5UZHHHH.cjs');
27
+ var _chunkMKS3TXYTcjs = require('../chunk-MKS3TXYT.cjs');
28
28
 
29
29
 
30
30
 
@@ -51,5 +51,5 @@ var _chunkF5UZHHHHcjs = require('../chunk-F5UZHHHH.cjs');
51
51
 
52
52
 
53
53
 
54
- exports.AuthProvider = _chunkF5UZHHHHcjs.AuthProvider; exports.AzureProvider = _chunkF5UZHHHHcjs.AzureProvider; exports.ConsentManager = _chunkF5UZHHHHcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkF5UZHHHHcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkF5UZHHHHcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkF5UZHHHHcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkF5UZHHHHcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkF5UZHHHHcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkF5UZHHHHcjs.DiskStore; exports.EncryptedTokenStorage = _chunkF5UZHHHHcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkF5UZHHHHcjs.GitHubProvider; exports.GoogleProvider = _chunkF5UZHHHHcjs.GoogleProvider; exports.JWKSVerifier = _chunkF5UZHHHHcjs.JWKSVerifier; exports.JWTIssuer = _chunkF5UZHHHHcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkF5UZHHHHcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkF5UZHHHHcjs.OAuthProvider; exports.OAuthProxy = _chunkF5UZHHHHcjs.OAuthProxy; exports.OAuthProxyError = _chunkF5UZHHHHcjs.OAuthProxyError; exports.PKCEUtils = _chunkF5UZHHHHcjs.PKCEUtils; exports.getAuthSession = _chunkF5UZHHHHcjs.getAuthSession; exports.requireAll = _chunkF5UZHHHHcjs.requireAll; exports.requireAny = _chunkF5UZHHHHcjs.requireAny; exports.requireAuth = _chunkF5UZHHHHcjs.requireAuth; exports.requireRole = _chunkF5UZHHHHcjs.requireRole; exports.requireScopes = _chunkF5UZHHHHcjs.requireScopes;
54
+ exports.AuthProvider = _chunkMKS3TXYTcjs.AuthProvider; exports.AzureProvider = _chunkMKS3TXYTcjs.AzureProvider; exports.ConsentManager = _chunkMKS3TXYTcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkMKS3TXYTcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkMKS3TXYTcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkMKS3TXYTcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkMKS3TXYTcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkMKS3TXYTcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkMKS3TXYTcjs.DiskStore; exports.EncryptedTokenStorage = _chunkMKS3TXYTcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkMKS3TXYTcjs.GitHubProvider; exports.GoogleProvider = _chunkMKS3TXYTcjs.GoogleProvider; exports.JWKSVerifier = _chunkMKS3TXYTcjs.JWKSVerifier; exports.JWTIssuer = _chunkMKS3TXYTcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkMKS3TXYTcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkMKS3TXYTcjs.OAuthProvider; exports.OAuthProxy = _chunkMKS3TXYTcjs.OAuthProxy; exports.OAuthProxyError = _chunkMKS3TXYTcjs.OAuthProxyError; exports.PKCEUtils = _chunkMKS3TXYTcjs.PKCEUtils; exports.getAuthSession = _chunkMKS3TXYTcjs.getAuthSession; exports.requireAll = _chunkMKS3TXYTcjs.requireAll; exports.requireAny = _chunkMKS3TXYTcjs.requireAny; exports.requireAuth = _chunkMKS3TXYTcjs.requireAuth; exports.requireRole = _chunkMKS3TXYTcjs.requireRole; exports.requireScopes = _chunkMKS3TXYTcjs.requireScopes;
55
55
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
- import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-CQ64Us1B.cjs';
2
- export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-CQ64Us1B.cjs';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-DmfNQge_.cjs';
2
+ export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-DmfNQge_.cjs';
3
3
 
4
4
  /**
5
5
  * Consent Management
@@ -1,5 +1,5 @@
1
- import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-CQ64Us1B.js';
2
- export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-CQ64Us1B.js';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-DmfNQge_.js';
2
+ export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-DmfNQge_.js';
3
3
 
4
4
  /**
5
5
  * Consent Management
@@ -24,7 +24,7 @@ import {
24
24
  requireAuth,
25
25
  requireRole,
26
26
  requireScopes
27
- } from "../chunk-WYT772UD.js";
27
+ } from "../chunk-GBQHIIQM.js";
28
28
  export {
29
29
  AuthProvider,
30
30
  AzureProvider,
@@ -1133,7 +1133,7 @@ var JWTIssuer = class {
1133
1133
  };
1134
1134
 
1135
1135
  // src/auth/utils/pkce.ts
1136
- import { createHash as createHash2, randomBytes as randomBytes2 } from "crypto";
1136
+ import { createHash as createHash2, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual3 } from "crypto";
1137
1137
  var PKCEUtils = class _PKCEUtils {
1138
1138
  /**
1139
1139
  * Generate a code challenge from a verifier
@@ -1190,11 +1190,11 @@ var PKCEUtils = class _PKCEUtils {
1190
1190
  return false;
1191
1191
  }
1192
1192
  if (method === "plain") {
1193
- return verifier === challenge;
1193
+ return equalsConstantTime(verifier, challenge);
1194
1194
  }
1195
1195
  if (method === "S256") {
1196
1196
  const computedChallenge = _PKCEUtils.generateChallenge(verifier, "S256");
1197
- return computedChallenge === challenge;
1197
+ return equalsConstantTime(computedChallenge, challenge);
1198
1198
  }
1199
1199
  return false;
1200
1200
  }
@@ -1207,6 +1207,11 @@ var PKCEUtils = class _PKCEUtils {
1207
1207
  return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
1208
1208
  }
1209
1209
  };
1210
+ function equalsConstantTime(a, b) {
1211
+ const bufA = Buffer.from(a, "utf8");
1212
+ const bufB = Buffer.from(b, "utf8");
1213
+ return bufA.length === bufB.length && timingSafeEqual3(bufA, bufB);
1214
+ }
1210
1215
 
1211
1216
  // src/auth/utils/tokenStore.ts
1212
1217
  import {
@@ -1474,6 +1479,14 @@ var OAuthProxy = class {
1474
1479
  "code_challenge_method required when code_challenge is present"
1475
1480
  );
1476
1481
  }
1482
+ if (params.code_challenge && params.code_challenge_method && !this.supportedCodeChallengeMethods().includes(
1483
+ params.code_challenge_method
1484
+ )) {
1485
+ throw new OAuthProxyError(
1486
+ "invalid_request",
1487
+ `Unsupported code_challenge_method: ${params.code_challenge_method}`
1488
+ );
1489
+ }
1477
1490
  const transaction = await this.createTransaction(params);
1478
1491
  if (this.config.consentRequired && !transaction.consentGiven) {
1479
1492
  return this.consentManager.createConsentResponse(
@@ -1590,7 +1603,7 @@ var OAuthProxy = class {
1590
1603
  authorizationResponseIssParameterSupported: true,
1591
1604
  // Clients prefer CIMD over DCR when both are offered.
1592
1605
  clientIdMetadataDocumentSupported: this.clientIdMetadata.enabled,
1593
- codeChallengeMethodsSupported: ["S256", "plain"],
1606
+ codeChallengeMethodsSupported: this.supportedCodeChallengeMethods(),
1594
1607
  grantTypesSupported: ["authorization_code", "refresh_token"],
1595
1608
  issuer: this.config.baseUrl,
1596
1609
  registrationEndpoint: `${this.config.baseUrl}/oauth/register`,
@@ -2475,6 +2488,19 @@ var OAuthProxy = class {
2475
2488
  this.cleanup();
2476
2489
  }, 6e4);
2477
2490
  }
2491
+ /**
2492
+ * PKCE challenge methods this proxy accepts, advertised in the authorization
2493
+ * server metadata and enforced at /oauth/authorize.
2494
+ *
2495
+ * S256 only by default. `plain` makes the challenge and the verifier the same
2496
+ * value, so the secret needed to redeem an authorization code is exposed
2497
+ * everywhere the authorization request is: browser history, referrer headers,
2498
+ * proxy logs. RFC 7636 §4.2 requires S256 of any client that can hash, and
2499
+ * OAuth 2.1 removes `plain` entirely.
2500
+ */
2501
+ supportedCodeChallengeMethods() {
2502
+ return this.config.allowPlainPkce ? ["S256", "plain"] : ["S256"];
2503
+ }
2478
2504
  /**
2479
2505
  * Atomically claim a token mapping, mirroring `OAuthProxyStateStore`: at most
2480
2506
  * one caller — across all processes sharing the storage — can receive a given
@@ -3121,4 +3147,4 @@ export {
3121
3147
  DiskStore,
3122
3148
  JWKSVerifier
3123
3149
  };
3124
- //# sourceMappingURL=chunk-WYT772UD.js.map
3150
+ //# sourceMappingURL=chunk-GBQHIIQM.js.map