@vitemcp/server 1.8.3 → 1.8.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/README.md CHANGED
@@ -388,7 +388,7 @@ The wrapper must stand alone: `{ structuredContent }`, optionally with `isError`
388
388
 
389
389
  #### Restricting who can call a tool
390
390
 
391
- A tool's optional `canAccess` receives the request's auth context and returns whether the caller may use it. Tools it rejects are filtered out of `tools/list` entirely.
391
+ A tool's optional `canAccess` receives the request's auth context and returns whether the caller may use it. Tools it rejects are filtered out of `tools/list` entirely. A caller who may use none of them gets an empty list rather than an error.
392
392
 
393
393
  ```typescript
394
394
  server.addTool({
@@ -664,6 +664,17 @@ declare class OAuthProxy {
664
664
  * Issue swapped tokens for refresh flow
665
665
  */
666
666
  private issueSwappedTokensForRefresh;
667
+ /**
668
+ * Whether the callback URL a transaction carries is still one its client
669
+ * declares.
670
+ *
671
+ * Resolved through `resolveClient` rather than a raw store lookup so a CIMD
672
+ * client is visible here too, and so a document that has since dropped the
673
+ * URI stops matching — the mid-flow revocation this check exists for.
674
+ * Loopback ports are matched per RFC 8252 §7.3, exactly as `authorize()`
675
+ * matched them, so the two legs cannot disagree about the same URI.
676
+ */
677
+ private isTransactionCallbackRegistered;
667
678
  /**
668
679
  * Match a parsed URI against an allow-list pattern, one URI component at a
669
680
  * time: scheme, host, port, then everything from the path onwards. A `*`
@@ -704,13 +715,13 @@ declare class OAuthProxy {
704
715
  */
705
716
  private refreshUpstreamTokens;
706
717
  /**
707
- * Redirect URIs the given client is allowed to use.
718
+ * The client behind a client_id, on whichever leg of the flow asks.
708
719
  *
709
720
  * A URL-formatted client_id is resolved as a Client ID Metadata Document
710
721
  * (the preferred mechanism on this revision); anything else must have been
711
- * registered through DCR.
722
+ * registered through DCR. Throws `invalid_client` when it is neither.
712
723
  */
713
- private resolveClientRedirectUris;
724
+ private resolveClient;
714
725
  /**
715
726
  * Put a claimed refresh-token mapping back after a rotation failed, keeping
716
727
  * whatever lifetime it had left.
@@ -664,6 +664,17 @@ declare class OAuthProxy {
664
664
  * Issue swapped tokens for refresh flow
665
665
  */
666
666
  private issueSwappedTokensForRefresh;
667
+ /**
668
+ * Whether the callback URL a transaction carries is still one its client
669
+ * declares.
670
+ *
671
+ * Resolved through `resolveClient` rather than a raw store lookup so a CIMD
672
+ * client is visible here too, and so a document that has since dropped the
673
+ * URI stops matching — the mid-flow revocation this check exists for.
674
+ * Loopback ports are matched per RFC 8252 §7.3, exactly as `authorize()`
675
+ * matched them, so the two legs cannot disagree about the same URI.
676
+ */
677
+ private isTransactionCallbackRegistered;
667
678
  /**
668
679
  * Match a parsed URI against an allow-list pattern, one URI component at a
669
680
  * time: scheme, host, port, then everything from the path onwards. A `*`
@@ -704,13 +715,13 @@ declare class OAuthProxy {
704
715
  */
705
716
  private refreshUpstreamTokens;
706
717
  /**
707
- * Redirect URIs the given client is allowed to use.
718
+ * The client behind a client_id, on whichever leg of the flow asks.
708
719
  *
709
720
  * A URL-formatted client_id is resolved as a Client ID Metadata Document
710
721
  * (the preferred mechanism on this revision); anything else must have been
711
- * registered through DCR.
722
+ * registered through DCR. Throws `invalid_client` when it is neither.
712
723
  */
713
- private resolveClientRedirectUris;
724
+ private resolveClient;
714
725
  /**
715
726
  * Put a claimed refresh-token mapping back after a rotation failed, keeping
716
727
  * whatever lifetime it had left.
package/dist/ViteMCP.cjs CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkIHV447K7cjs = require('./chunk-IHV447K7.cjs');
13
+ var _chunkWL4YFT27cjs = require('./chunk-WL4YFT27.cjs');
14
14
 
15
15
 
16
16
 
@@ -25,7 +25,7 @@ var _chunkIHV447K7cjs = require('./chunk-IHV447K7.cjs');
25
25
 
26
26
 
27
27
 
28
- var _chunkVTEMGFQZcjs = require('./chunk-VTEMGFQZ.cjs');
28
+ var _chunkY3GRHB77cjs = require('./chunk-Y3GRHB77.cjs');
29
29
 
30
30
 
31
31
 
@@ -51,5 +51,5 @@ var _chunkVTEMGFQZcjs = require('./chunk-VTEMGFQZ.cjs');
51
51
 
52
52
 
53
53
 
54
- exports.AuthProvider = _chunkVTEMGFQZcjs.AuthProvider; exports.AzureProvider = _chunkVTEMGFQZcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkIHV447K7cjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkVTEMGFQZcjs.GitHubProvider; exports.GoogleProvider = _chunkVTEMGFQZcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkIHV447K7cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkVTEMGFQZcjs.OAuthProvider; exports.OAuthProxy = _chunkVTEMGFQZcjs.OAuthProxy; exports.OAuthProxyError = _chunkVTEMGFQZcjs.OAuthProxyError; exports.ServerState = _chunkIHV447K7cjs.ServerState; exports.UnexpectedStateError = _chunkIHV447K7cjs.UnexpectedStateError; exports.UserError = _chunkIHV447K7cjs.UserError; exports.ViteMCP = _chunkIHV447K7cjs.ViteMCP; exports.ViteMCPError = _chunkIHV447K7cjs.ViteMCPError; exports.audioContent = _chunkIHV447K7cjs.audioContent; exports.delay = _chunkIHV447K7cjs.delay; exports.getAuthSession = _chunkVTEMGFQZcjs.getAuthSession; exports.imageContent = _chunkIHV447K7cjs.imageContent; exports.jsonSchemaAdapter = _chunkIHV447K7cjs.jsonSchemaAdapter; exports.requireAll = _chunkVTEMGFQZcjs.requireAll; exports.requireAny = _chunkVTEMGFQZcjs.requireAny; exports.requireAuth = _chunkVTEMGFQZcjs.requireAuth; exports.requireRole = _chunkVTEMGFQZcjs.requireRole; exports.requireScopes = _chunkVTEMGFQZcjs.requireScopes;
54
+ exports.AuthProvider = _chunkY3GRHB77cjs.AuthProvider; exports.AzureProvider = _chunkY3GRHB77cjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkWL4YFT27cjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkY3GRHB77cjs.GitHubProvider; exports.GoogleProvider = _chunkY3GRHB77cjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkWL4YFT27cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkY3GRHB77cjs.OAuthProvider; exports.OAuthProxy = _chunkY3GRHB77cjs.OAuthProxy; exports.OAuthProxyError = _chunkY3GRHB77cjs.OAuthProxyError; exports.ServerState = _chunkWL4YFT27cjs.ServerState; exports.UnexpectedStateError = _chunkWL4YFT27cjs.UnexpectedStateError; exports.UserError = _chunkWL4YFT27cjs.UserError; exports.ViteMCP = _chunkWL4YFT27cjs.ViteMCP; exports.ViteMCPError = _chunkWL4YFT27cjs.ViteMCPError; exports.audioContent = _chunkWL4YFT27cjs.audioContent; exports.delay = _chunkWL4YFT27cjs.delay; exports.getAuthSession = _chunkY3GRHB77cjs.getAuthSession; exports.imageContent = _chunkWL4YFT27cjs.imageContent; exports.jsonSchemaAdapter = _chunkWL4YFT27cjs.jsonSchemaAdapter; exports.requireAll = _chunkY3GRHB77cjs.requireAll; exports.requireAny = _chunkY3GRHB77cjs.requireAny; exports.requireAuth = _chunkY3GRHB77cjs.requireAuth; exports.requireRole = _chunkY3GRHB77cjs.requireRole; exports.requireScopes = _chunkY3GRHB77cjs.requireScopes;
55
55
  //# 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-CWBi3c3D.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-CWBi3c3D.cjs';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-COBBSCMI.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-COBBSCMI.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-CWBi3c3D.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-CWBi3c3D.js';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-COBBSCMI.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-COBBSCMI.js';
9
9
 
10
10
  declare class DiscoveryDocumentCache {
11
11
  #private;
package/dist/ViteMCP.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  delay,
11
11
  imageContent,
12
12
  jsonSchemaAdapter
13
- } from "./chunk-XT3EUCZT.js";
13
+ } from "./chunk-IVYCNHWC.js";
14
14
  import {
15
15
  AuthProvider,
16
16
  AzureProvider,
@@ -25,7 +25,7 @@ import {
25
25
  requireAuth,
26
26
  requireRole,
27
27
  requireScopes
28
- } from "./chunk-GCCQBATS.js";
28
+ } from "./chunk-5KNSU2F3.js";
29
29
  export {
30
30
  AuthProvider,
31
31
  AzureProvider,
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunkVTEMGFQZcjs = require('../chunk-VTEMGFQZ.cjs');
27
+ var _chunkY3GRHB77cjs = require('../chunk-Y3GRHB77.cjs');
28
28
 
29
29
 
30
30
 
@@ -51,5 +51,5 @@ var _chunkVTEMGFQZcjs = require('../chunk-VTEMGFQZ.cjs');
51
51
 
52
52
 
53
53
 
54
- exports.AuthProvider = _chunkVTEMGFQZcjs.AuthProvider; exports.AzureProvider = _chunkVTEMGFQZcjs.AzureProvider; exports.ConsentManager = _chunkVTEMGFQZcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkVTEMGFQZcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkVTEMGFQZcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkVTEMGFQZcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkVTEMGFQZcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkVTEMGFQZcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkVTEMGFQZcjs.DiskStore; exports.EncryptedTokenStorage = _chunkVTEMGFQZcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkVTEMGFQZcjs.GitHubProvider; exports.GoogleProvider = _chunkVTEMGFQZcjs.GoogleProvider; exports.JWKSVerifier = _chunkVTEMGFQZcjs.JWKSVerifier; exports.JWTIssuer = _chunkVTEMGFQZcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkVTEMGFQZcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkVTEMGFQZcjs.OAuthProvider; exports.OAuthProxy = _chunkVTEMGFQZcjs.OAuthProxy; exports.OAuthProxyError = _chunkVTEMGFQZcjs.OAuthProxyError; exports.PKCEUtils = _chunkVTEMGFQZcjs.PKCEUtils; exports.getAuthSession = _chunkVTEMGFQZcjs.getAuthSession; exports.requireAll = _chunkVTEMGFQZcjs.requireAll; exports.requireAny = _chunkVTEMGFQZcjs.requireAny; exports.requireAuth = _chunkVTEMGFQZcjs.requireAuth; exports.requireRole = _chunkVTEMGFQZcjs.requireRole; exports.requireScopes = _chunkVTEMGFQZcjs.requireScopes;
54
+ exports.AuthProvider = _chunkY3GRHB77cjs.AuthProvider; exports.AzureProvider = _chunkY3GRHB77cjs.AzureProvider; exports.ConsentManager = _chunkY3GRHB77cjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkY3GRHB77cjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkY3GRHB77cjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkY3GRHB77cjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkY3GRHB77cjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkY3GRHB77cjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkY3GRHB77cjs.DiskStore; exports.EncryptedTokenStorage = _chunkY3GRHB77cjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkY3GRHB77cjs.GitHubProvider; exports.GoogleProvider = _chunkY3GRHB77cjs.GoogleProvider; exports.JWKSVerifier = _chunkY3GRHB77cjs.JWKSVerifier; exports.JWTIssuer = _chunkY3GRHB77cjs.JWTIssuer; exports.MemoryTokenStorage = _chunkY3GRHB77cjs.MemoryTokenStorage; exports.OAuthProvider = _chunkY3GRHB77cjs.OAuthProvider; exports.OAuthProxy = _chunkY3GRHB77cjs.OAuthProxy; exports.OAuthProxyError = _chunkY3GRHB77cjs.OAuthProxyError; exports.PKCEUtils = _chunkY3GRHB77cjs.PKCEUtils; exports.getAuthSession = _chunkY3GRHB77cjs.getAuthSession; exports.requireAll = _chunkY3GRHB77cjs.requireAll; exports.requireAny = _chunkY3GRHB77cjs.requireAny; exports.requireAuth = _chunkY3GRHB77cjs.requireAuth; exports.requireRole = _chunkY3GRHB77cjs.requireRole; exports.requireScopes = _chunkY3GRHB77cjs.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-CWBi3c3D.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-CWBi3c3D.cjs';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-COBBSCMI.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-COBBSCMI.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-CWBi3c3D.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-CWBi3c3D.js';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-COBBSCMI.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-COBBSCMI.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-GCCQBATS.js";
27
+ } from "../chunk-5KNSU2F3.js";
28
28
  export {
29
29
  AuthProvider,
30
30
  AzureProvider,
@@ -444,12 +444,6 @@ var OAuthProxyStateStore = class {
444
444
  }
445
445
  return parsed.data;
446
446
  }
447
- async isTransactionCallbackRegistered(transaction) {
448
- const registeredClient = await this.getRegisteredClientByClientId(
449
- transaction.clientId
450
- );
451
- return registeredClient?.redirectUris.includes(transaction.clientCallbackUrl) ?? false;
452
- }
453
447
  /**
454
448
  * Record that an authorization code has been redeemed, so a later attempt
455
449
  * gets "already used" rather than looking like an unknown code. Keyed and
@@ -1132,6 +1126,40 @@ var JWTIssuer = class {
1132
1126
  }
1133
1127
  };
1134
1128
 
1129
+ // src/auth/utils/loopbackRedirect.ts
1130
+ var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["::1", "127.0.0.1", "localhost"]);
1131
+ var parse = (uri) => {
1132
+ try {
1133
+ return new URL(uri);
1134
+ } catch {
1135
+ return null;
1136
+ }
1137
+ };
1138
+ function loopbackRedirectMatches(declared, requested) {
1139
+ if (declared === requested) {
1140
+ return true;
1141
+ }
1142
+ const a = parse(declared);
1143
+ const b = parse(requested);
1144
+ if (!a || !b) {
1145
+ return false;
1146
+ }
1147
+ if (a.protocol !== "http:" || b.protocol !== "http:") {
1148
+ return false;
1149
+ }
1150
+ const host = a.hostname.replace(/^\[|\]$/g, "");
1151
+ if (!LOOPBACK_HOSTS.has(host) || a.hostname !== b.hostname) {
1152
+ return false;
1153
+ }
1154
+ if (a.port !== "") {
1155
+ return false;
1156
+ }
1157
+ if (a.username !== "" || a.password !== "" || b.username !== "" || b.password !== "") {
1158
+ return false;
1159
+ }
1160
+ return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash;
1161
+ }
1162
+
1135
1163
  // src/auth/utils/pkce.ts
1136
1164
  import { createHash as createHash2, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual3 } from "crypto";
1137
1165
  var PKCEUtils = class _PKCEUtils {
@@ -1476,10 +1504,11 @@ var OAuthProxy = class {
1476
1504
  "Only 'code' response type is supported"
1477
1505
  );
1478
1506
  }
1479
- const registeredUris = await this.resolveClientRedirectUris(
1480
- params.client_id
1481
- );
1482
- if (!registeredUris.includes(params.redirect_uri)) {
1507
+ const registeredClient = await this.resolveClient(params.client_id);
1508
+ const registeredUris = registeredClient.redirectUris;
1509
+ if (!registeredUris.some(
1510
+ (uri) => loopbackRedirectMatches(uri, params.redirect_uri)
1511
+ )) {
1483
1512
  throw new OAuthProxyError(
1484
1513
  "invalid_request",
1485
1514
  "redirect_uri is not registered for this client"
@@ -1529,10 +1558,7 @@ var OAuthProxy = class {
1529
1558
  "Only authorization_code grant type is supported"
1530
1559
  );
1531
1560
  }
1532
- const registeredClient = await this.stateStore.getRegisteredClientByClientId(request2.client_id);
1533
- if (!registeredClient) {
1534
- throw new OAuthProxyError("invalid_client", "Unknown client_id");
1535
- }
1561
+ await this.resolveClient(request2.client_id);
1536
1562
  const consumed = await this.stateStore.consumeClientCode(request2.code);
1537
1563
  if (!consumed) {
1538
1564
  throw new OAuthProxyError(
@@ -1623,9 +1649,15 @@ var OAuthProxy = class {
1623
1649
  responseTypesSupported: ["code"],
1624
1650
  scopesSupported: this.config.scopes || [],
1625
1651
  tokenEndpoint: `${this.config.baseUrl}/oauth/token`,
1652
+ // RFC 8414 §2. A CIMD client is a public client: it has no registration
1653
+ // response to carry a secret, and authenticates the exchange with PKCE
1654
+ // alone. A client that reads this list to pick an auth method finds
1655
+ // nothing it can use unless "none" is advertised alongside the
1656
+ // confidential methods DCR clients use.
1626
1657
  tokenEndpointAuthMethodsSupported: [
1627
1658
  "client_secret_basic",
1628
- "client_secret_post"
1659
+ "client_secret_post",
1660
+ ...this.clientIdMetadata.enabled ? ["none"] : []
1629
1661
  ]
1630
1662
  };
1631
1663
  }
@@ -1651,7 +1683,7 @@ var OAuthProxy = class {
1651
1683
  if (!transaction) {
1652
1684
  throw new OAuthProxyError("invalid_request", "Invalid or expired state");
1653
1685
  }
1654
- if (!await this.stateStore.isTransactionCallbackRegistered(transaction)) {
1686
+ if (!await this.isTransactionCallbackRegistered(transaction)) {
1655
1687
  throw new OAuthProxyError(
1656
1688
  "invalid_request",
1657
1689
  "Transaction callback URL is not registered"
@@ -1705,7 +1737,7 @@ var OAuthProxy = class {
1705
1737
  }
1706
1738
  if (action === "deny") {
1707
1739
  await this.stateStore.deleteTransaction(transactionId);
1708
- if (!await this.stateStore.isTransactionCallbackRegistered(transaction)) {
1740
+ if (!await this.isTransactionCallbackRegistered(transaction)) {
1709
1741
  throw new OAuthProxyError(
1710
1742
  "invalid_request",
1711
1743
  "Transaction callback URL is not registered"
@@ -2317,6 +2349,27 @@ var OAuthProxy = class {
2317
2349
  }
2318
2350
  return response;
2319
2351
  }
2352
+ /**
2353
+ * Whether the callback URL a transaction carries is still one its client
2354
+ * declares.
2355
+ *
2356
+ * Resolved through `resolveClient` rather than a raw store lookup so a CIMD
2357
+ * client is visible here too, and so a document that has since dropped the
2358
+ * URI stops matching — the mid-flow revocation this check exists for.
2359
+ * Loopback ports are matched per RFC 8252 §7.3, exactly as `authorize()`
2360
+ * matched them, so the two legs cannot disagree about the same URI.
2361
+ */
2362
+ async isTransactionCallbackRegistered(transaction) {
2363
+ let client;
2364
+ try {
2365
+ client = await this.resolveClient(transaction.clientId);
2366
+ } catch {
2367
+ return false;
2368
+ }
2369
+ return client.redirectUris.some(
2370
+ (uri) => loopbackRedirectMatches(uri, transaction.clientCallbackUrl)
2371
+ );
2372
+ }
2320
2373
  /**
2321
2374
  * Match a parsed URI against an allow-list pattern, one URI component at a
2322
2375
  * time: scheme, host, port, then everything from the path onwards. A `*`
@@ -2483,13 +2536,17 @@ var OAuthProxy = class {
2483
2536
  };
2484
2537
  }
2485
2538
  /**
2486
- * Redirect URIs the given client is allowed to use.
2539
+ * The client behind a client_id, on whichever leg of the flow asks.
2487
2540
  *
2488
2541
  * A URL-formatted client_id is resolved as a Client ID Metadata Document
2489
2542
  * (the preferred mechanism on this revision); anything else must have been
2490
- * registered through DCR.
2543
+ * registered through DCR. Throws `invalid_client` when it is neither.
2491
2544
  */
2492
- async resolveClientRedirectUris(clientId) {
2545
+ async resolveClient(clientId) {
2546
+ const registered = await this.stateStore.getRegisteredClientByClientId(clientId);
2547
+ if (registered) {
2548
+ return registered;
2549
+ }
2493
2550
  if (this.clientIdMetadata.enabled && isClientIdMetadataUrl(clientId)) {
2494
2551
  let metadata;
2495
2552
  try {
@@ -2508,13 +2565,20 @@ var OAuthProxy = class {
2508
2565
  );
2509
2566
  }
2510
2567
  }
2511
- return metadata.redirect_uris;
2512
- }
2513
- const registeredClient = await this.stateStore.getRegisteredClientByClientId(clientId);
2514
- if (!registeredClient) {
2515
- throw new OAuthProxyError("invalid_client", "Unknown client_id");
2568
+ return {
2569
+ callbackUrl: metadata.redirect_uris[0],
2570
+ clientId,
2571
+ clientSecret: void 0,
2572
+ metadata: {
2573
+ client_name: metadata.client_name,
2574
+ client_uri: metadata.client_uri,
2575
+ redirect_uris: metadata.redirect_uris
2576
+ },
2577
+ redirectUris: metadata.redirect_uris,
2578
+ registeredAt: /* @__PURE__ */ new Date()
2579
+ };
2516
2580
  }
2517
- return registeredClient.redirectUris;
2581
+ throw new OAuthProxyError("invalid_client", "Unknown client_id");
2518
2582
  }
2519
2583
  /**
2520
2584
  * Put a claimed refresh-token mapping back after a rotation failed, keeping
@@ -3309,4 +3373,4 @@ export {
3309
3373
  DiskStore,
3310
3374
  JWKSVerifier
3311
3375
  };
3312
- //# sourceMappingURL=chunk-GCCQBATS.js.map
3376
+ //# sourceMappingURL=chunk-5KNSU2F3.js.map