@vitemcp/server 1.9.8 → 1.9.9

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.
@@ -24,6 +24,11 @@ interface ClientIdMetadataOptions {
24
24
  declare const DEFAULT_ACCESS_TOKEN_TTL = 3600;
25
25
  declare const DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = 31536000;
26
26
  declare const DEFAULT_REFRESH_TOKEN_TTL = 2592000;
27
+ /**
28
+ * The token endpoint authentication methods the proxy can verify, and so the
29
+ * only ones a client may register with.
30
+ */
31
+ declare const TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_basic", "client_secret_post", "none"];
27
32
  declare const DEFAULT_AUTHORIZATION_CODE_TTL = 300;
28
33
  declare const DEFAULT_TRANSACTION_TTL = 600;
29
34
  /**
@@ -386,6 +391,17 @@ interface ProxyDCRClient {
386
391
  * Registration.
387
392
  */
388
393
  source?: "cimd";
394
+ /**
395
+ * How the client authenticates at the token endpoint, as it registered.
396
+ * `"none"` is a public client: it is issued no secret and must use S256
397
+ * PKCE. Either secret method obliges it to authenticate on every token
398
+ * request.
399
+ *
400
+ * Absent on registrations written before this was recorded, when every
401
+ * client was issued a secret whatever it asked for. Those are treated as
402
+ * public clients that may still authenticate with that secret.
403
+ */
404
+ tokenEndpointAuthMethod?: TokenEndpointAuthMethod;
389
405
  }
390
406
  /**
391
407
  * OAuth refresh token request
@@ -397,11 +413,23 @@ interface RefreshRequest {
397
413
  refresh_token: string;
398
414
  scope?: string;
399
415
  }
416
+ /**
417
+ * Token endpoint authentication methods a Dynamic Client Registration may ask
418
+ * for (RFC 7591 §2).
419
+ */
420
+ type TokenEndpointAuthMethod = (typeof TOKEN_ENDPOINT_AUTH_METHODS)[number];
400
421
  /**
401
422
  * Token mapping for JWT swap pattern
402
423
  * Maps JTI to upstream token reference
403
424
  */
404
425
  interface TokenMapping {
426
+ /**
427
+ * Whether the client authenticated with its secret when this token was
428
+ * issued. A refresh token issued that way is only redeemed by a client that
429
+ * authenticates again; otherwise omitting the secret would turn it back into
430
+ * a bearer token.
431
+ */
432
+ clientAuthenticated?: boolean;
405
433
  clientId: string;
406
434
  /** Creation timestamp */
407
435
  createdAt: Date;
@@ -595,6 +623,20 @@ declare class OAuthProxy {
595
623
  * RFC 7591 Dynamic Client Registration
596
624
  */
597
625
  registerClient(request: DCRRequest): Promise<DCRResponse>;
626
+ /**
627
+ * RFC 6749 §2.3 / §3.2.1: identify the client behind a token request and,
628
+ * when it presents a secret, authenticate it.
629
+ *
630
+ * A client registered with a secret method must present its secret. A
631
+ * public client must not present one: it was issued none. A registration
632
+ * that predates recorded auth methods may do either — it was issued a
633
+ * secret whatever it asked for — and is treated as unauthenticated when it
634
+ * leaves it out, which the grants then hold it to.
635
+ *
636
+ * Throws `invalid_client` on any failure. Nothing here touches grant state,
637
+ * so a caller that fails cannot spend a code or refresh token.
638
+ */
639
+ private authenticateClient;
598
640
  /**
599
641
  * Calculate access token TTL from upstream tokens
600
642
  */
@@ -716,6 +758,12 @@ declare class OAuthProxy {
716
758
  * GitHub Apps return URL-encoded format, most providers return JSON
717
759
  */
718
760
  private parseTokenResponse;
761
+ /**
762
+ * Storage key for the client binding of a passthrough-mode upstream refresh
763
+ * token. Keyed by its hash: storage keys are not encrypted, and the token
764
+ * itself is a live upstream credential.
765
+ */
766
+ private passthroughRefreshKey;
719
767
  /**
720
768
  * Redirect to upstream OAuth provider
721
769
  */
@@ -742,6 +790,12 @@ declare class OAuthProxy {
742
790
  * `expiresAt`.
743
791
  */
744
792
  private restoreMapping;
793
+ /**
794
+ * Record which client a passthrough-mode upstream refresh token was handed
795
+ * to. It lives as long as the upstream says the token does, or as the
796
+ * configured refresh-token lifetime when it does not say.
797
+ */
798
+ private savePassthroughRefreshBinding;
745
799
  /**
746
800
  * Start periodic cleanup of expired transactions and codes
747
801
  */
@@ -24,6 +24,11 @@ interface ClientIdMetadataOptions {
24
24
  declare const DEFAULT_ACCESS_TOKEN_TTL = 3600;
25
25
  declare const DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = 31536000;
26
26
  declare const DEFAULT_REFRESH_TOKEN_TTL = 2592000;
27
+ /**
28
+ * The token endpoint authentication methods the proxy can verify, and so the
29
+ * only ones a client may register with.
30
+ */
31
+ declare const TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_basic", "client_secret_post", "none"];
27
32
  declare const DEFAULT_AUTHORIZATION_CODE_TTL = 300;
28
33
  declare const DEFAULT_TRANSACTION_TTL = 600;
29
34
  /**
@@ -386,6 +391,17 @@ interface ProxyDCRClient {
386
391
  * Registration.
387
392
  */
388
393
  source?: "cimd";
394
+ /**
395
+ * How the client authenticates at the token endpoint, as it registered.
396
+ * `"none"` is a public client: it is issued no secret and must use S256
397
+ * PKCE. Either secret method obliges it to authenticate on every token
398
+ * request.
399
+ *
400
+ * Absent on registrations written before this was recorded, when every
401
+ * client was issued a secret whatever it asked for. Those are treated as
402
+ * public clients that may still authenticate with that secret.
403
+ */
404
+ tokenEndpointAuthMethod?: TokenEndpointAuthMethod;
389
405
  }
390
406
  /**
391
407
  * OAuth refresh token request
@@ -397,11 +413,23 @@ interface RefreshRequest {
397
413
  refresh_token: string;
398
414
  scope?: string;
399
415
  }
416
+ /**
417
+ * Token endpoint authentication methods a Dynamic Client Registration may ask
418
+ * for (RFC 7591 §2).
419
+ */
420
+ type TokenEndpointAuthMethod = (typeof TOKEN_ENDPOINT_AUTH_METHODS)[number];
400
421
  /**
401
422
  * Token mapping for JWT swap pattern
402
423
  * Maps JTI to upstream token reference
403
424
  */
404
425
  interface TokenMapping {
426
+ /**
427
+ * Whether the client authenticated with its secret when this token was
428
+ * issued. A refresh token issued that way is only redeemed by a client that
429
+ * authenticates again; otherwise omitting the secret would turn it back into
430
+ * a bearer token.
431
+ */
432
+ clientAuthenticated?: boolean;
405
433
  clientId: string;
406
434
  /** Creation timestamp */
407
435
  createdAt: Date;
@@ -595,6 +623,20 @@ declare class OAuthProxy {
595
623
  * RFC 7591 Dynamic Client Registration
596
624
  */
597
625
  registerClient(request: DCRRequest): Promise<DCRResponse>;
626
+ /**
627
+ * RFC 6749 §2.3 / §3.2.1: identify the client behind a token request and,
628
+ * when it presents a secret, authenticate it.
629
+ *
630
+ * A client registered with a secret method must present its secret. A
631
+ * public client must not present one: it was issued none. A registration
632
+ * that predates recorded auth methods may do either — it was issued a
633
+ * secret whatever it asked for — and is treated as unauthenticated when it
634
+ * leaves it out, which the grants then hold it to.
635
+ *
636
+ * Throws `invalid_client` on any failure. Nothing here touches grant state,
637
+ * so a caller that fails cannot spend a code or refresh token.
638
+ */
639
+ private authenticateClient;
598
640
  /**
599
641
  * Calculate access token TTL from upstream tokens
600
642
  */
@@ -716,6 +758,12 @@ declare class OAuthProxy {
716
758
  * GitHub Apps return URL-encoded format, most providers return JSON
717
759
  */
718
760
  private parseTokenResponse;
761
+ /**
762
+ * Storage key for the client binding of a passthrough-mode upstream refresh
763
+ * token. Keyed by its hash: storage keys are not encrypted, and the token
764
+ * itself is a live upstream credential.
765
+ */
766
+ private passthroughRefreshKey;
719
767
  /**
720
768
  * Redirect to upstream OAuth provider
721
769
  */
@@ -742,6 +790,12 @@ declare class OAuthProxy {
742
790
  * `expiresAt`.
743
791
  */
744
792
  private restoreMapping;
793
+ /**
794
+ * Record which client a passthrough-mode upstream refresh token was handed
795
+ * to. It lives as long as the upstream says the token does, or as the
796
+ * configured refresh-token lifetime when it does not say.
797
+ */
798
+ private savePassthroughRefreshBinding;
745
799
  /**
746
800
  * Start periodic cleanup of expired transactions and codes
747
801
  */
package/dist/ViteMCP.cjs CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkXU7XBDZIcjs = require('./chunk-XU7XBDZI.cjs');
13
+ var _chunk2FAJF3V6cjs = require('./chunk-2FAJF3V6.cjs');
14
14
 
15
15
 
16
16
 
@@ -25,7 +25,7 @@ var _chunkXU7XBDZIcjs = require('./chunk-XU7XBDZI.cjs');
25
25
 
26
26
 
27
27
 
28
- var _chunkNLFL6ISLcjs = require('./chunk-NLFL6ISL.cjs');
28
+ var _chunkPNWCRGJYcjs = require('./chunk-PNWCRGJY.cjs');
29
29
  require('./chunk-DURXYPPR.cjs');
30
30
 
31
31
 
@@ -52,5 +52,5 @@ require('./chunk-DURXYPPR.cjs');
52
52
 
53
53
 
54
54
 
55
- exports.AuthProvider = _chunkNLFL6ISLcjs.AuthProvider; exports.AzureProvider = _chunkNLFL6ISLcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkXU7XBDZIcjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkNLFL6ISLcjs.GitHubProvider; exports.GoogleProvider = _chunkNLFL6ISLcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkXU7XBDZIcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkNLFL6ISLcjs.OAuthProvider; exports.OAuthProxy = _chunkNLFL6ISLcjs.OAuthProxy; exports.OAuthProxyError = _chunkNLFL6ISLcjs.OAuthProxyError; exports.ServerState = _chunkXU7XBDZIcjs.ServerState; exports.UnexpectedStateError = _chunkXU7XBDZIcjs.UnexpectedStateError; exports.UserError = _chunkXU7XBDZIcjs.UserError; exports.ViteMCP = _chunkXU7XBDZIcjs.ViteMCP; exports.ViteMCPError = _chunkXU7XBDZIcjs.ViteMCPError; exports.audioContent = _chunkXU7XBDZIcjs.audioContent; exports.delay = _chunkXU7XBDZIcjs.delay; exports.getAuthSession = _chunkNLFL6ISLcjs.getAuthSession; exports.imageContent = _chunkXU7XBDZIcjs.imageContent; exports.jsonSchemaAdapter = _chunkXU7XBDZIcjs.jsonSchemaAdapter; exports.requireAll = _chunkNLFL6ISLcjs.requireAll; exports.requireAny = _chunkNLFL6ISLcjs.requireAny; exports.requireAuth = _chunkNLFL6ISLcjs.requireAuth; exports.requireRole = _chunkNLFL6ISLcjs.requireRole; exports.requireScopes = _chunkNLFL6ISLcjs.requireScopes;
55
+ exports.AuthProvider = _chunkPNWCRGJYcjs.AuthProvider; exports.AzureProvider = _chunkPNWCRGJYcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunk2FAJF3V6cjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkPNWCRGJYcjs.GitHubProvider; exports.GoogleProvider = _chunkPNWCRGJYcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunk2FAJF3V6cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkPNWCRGJYcjs.OAuthProvider; exports.OAuthProxy = _chunkPNWCRGJYcjs.OAuthProxy; exports.OAuthProxyError = _chunkPNWCRGJYcjs.OAuthProxyError; exports.ServerState = _chunk2FAJF3V6cjs.ServerState; exports.UnexpectedStateError = _chunk2FAJF3V6cjs.UnexpectedStateError; exports.UserError = _chunk2FAJF3V6cjs.UserError; exports.ViteMCP = _chunk2FAJF3V6cjs.ViteMCP; exports.ViteMCPError = _chunk2FAJF3V6cjs.ViteMCPError; exports.audioContent = _chunk2FAJF3V6cjs.audioContent; exports.delay = _chunk2FAJF3V6cjs.delay; exports.getAuthSession = _chunkPNWCRGJYcjs.getAuthSession; exports.imageContent = _chunk2FAJF3V6cjs.imageContent; exports.jsonSchemaAdapter = _chunk2FAJF3V6cjs.jsonSchemaAdapter; exports.requireAll = _chunkPNWCRGJYcjs.requireAll; exports.requireAny = _chunkPNWCRGJYcjs.requireAny; exports.requireAuth = _chunkPNWCRGJYcjs.requireAuth; exports.requireRole = _chunkPNWCRGJYcjs.requireRole; exports.requireScopes = _chunkPNWCRGJYcjs.requireScopes;
56
56
  //# 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-BaPwgWny.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-BaPwgWny.cjs';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-Dt3F-oDh.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-Dt3F-oDh.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-BaPwgWny.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-BaPwgWny.js';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-Dt3F-oDh.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-Dt3F-oDh.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-QZ6S3FM5.js";
13
+ } from "./chunk-UVKIOOZA.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-76HUSLES.js";
28
+ } from "./chunk-ZVK5GKEO.js";
29
29
  import "./chunk-TYR2KJIV.js";
30
30
  export {
31
31
  AuthProvider,
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunkNLFL6ISLcjs = require('../chunk-NLFL6ISL.cjs');
27
+ var _chunkPNWCRGJYcjs = require('../chunk-PNWCRGJY.cjs');
28
28
 
29
29
 
30
30
 
@@ -51,5 +51,5 @@ var _chunkNLFL6ISLcjs = require('../chunk-NLFL6ISL.cjs');
51
51
 
52
52
 
53
53
 
54
- exports.AuthProvider = _chunkNLFL6ISLcjs.AuthProvider; exports.AzureProvider = _chunkNLFL6ISLcjs.AzureProvider; exports.ConsentManager = _chunkNLFL6ISLcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkNLFL6ISLcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkNLFL6ISLcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkNLFL6ISLcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkNLFL6ISLcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkNLFL6ISLcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkNLFL6ISLcjs.DiskStore; exports.EncryptedTokenStorage = _chunkNLFL6ISLcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkNLFL6ISLcjs.GitHubProvider; exports.GoogleProvider = _chunkNLFL6ISLcjs.GoogleProvider; exports.JWKSVerifier = _chunkNLFL6ISLcjs.JWKSVerifier; exports.JWTIssuer = _chunkNLFL6ISLcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkNLFL6ISLcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkNLFL6ISLcjs.OAuthProvider; exports.OAuthProxy = _chunkNLFL6ISLcjs.OAuthProxy; exports.OAuthProxyError = _chunkNLFL6ISLcjs.OAuthProxyError; exports.PKCEUtils = _chunkNLFL6ISLcjs.PKCEUtils; exports.getAuthSession = _chunkNLFL6ISLcjs.getAuthSession; exports.requireAll = _chunkNLFL6ISLcjs.requireAll; exports.requireAny = _chunkNLFL6ISLcjs.requireAny; exports.requireAuth = _chunkNLFL6ISLcjs.requireAuth; exports.requireRole = _chunkNLFL6ISLcjs.requireRole; exports.requireScopes = _chunkNLFL6ISLcjs.requireScopes;
54
+ exports.AuthProvider = _chunkPNWCRGJYcjs.AuthProvider; exports.AzureProvider = _chunkPNWCRGJYcjs.AzureProvider; exports.ConsentManager = _chunkPNWCRGJYcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkPNWCRGJYcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkPNWCRGJYcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkPNWCRGJYcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkPNWCRGJYcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkPNWCRGJYcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkPNWCRGJYcjs.DiskStore; exports.EncryptedTokenStorage = _chunkPNWCRGJYcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkPNWCRGJYcjs.GitHubProvider; exports.GoogleProvider = _chunkPNWCRGJYcjs.GoogleProvider; exports.JWKSVerifier = _chunkPNWCRGJYcjs.JWKSVerifier; exports.JWTIssuer = _chunkPNWCRGJYcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkPNWCRGJYcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkPNWCRGJYcjs.OAuthProvider; exports.OAuthProxy = _chunkPNWCRGJYcjs.OAuthProxy; exports.OAuthProxyError = _chunkPNWCRGJYcjs.OAuthProxyError; exports.PKCEUtils = _chunkPNWCRGJYcjs.PKCEUtils; exports.getAuthSession = _chunkPNWCRGJYcjs.getAuthSession; exports.requireAll = _chunkPNWCRGJYcjs.requireAll; exports.requireAny = _chunkPNWCRGJYcjs.requireAny; exports.requireAuth = _chunkPNWCRGJYcjs.requireAuth; exports.requireRole = _chunkPNWCRGJYcjs.requireRole; exports.requireScopes = _chunkPNWCRGJYcjs.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-BaPwgWny.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-BaPwgWny.cjs';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-Dt3F-oDh.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-Dt3F-oDh.cjs';
3
3
 
4
4
  /**
5
5
  * Consent Management
@@ -154,6 +154,14 @@ interface JWTClaims {
154
154
  jti: string;
155
155
  /** Scopes */
156
156
  scope: string[];
157
+ /**
158
+ * Which kind of token this is. Access and refresh tokens share a signing
159
+ * key, audience and claim set, so without this either one verifies as the
160
+ * other: an access token — sent on every request — could be redeemed for a
161
+ * refresh token, and a refresh token presented as a bearer credential.
162
+ * Absent from tokens issued before it existed; those are refused as both.
163
+ */
164
+ token_use?: "access" | "refresh";
157
165
  }
158
166
  /**
159
167
  * JWT Issuer configuration
@@ -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-BaPwgWny.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-BaPwgWny.js';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-Dt3F-oDh.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-Dt3F-oDh.js';
3
3
 
4
4
  /**
5
5
  * Consent Management
@@ -154,6 +154,14 @@ interface JWTClaims {
154
154
  jti: string;
155
155
  /** Scopes */
156
156
  scope: string[];
157
+ /**
158
+ * Which kind of token this is. Access and refresh tokens share a signing
159
+ * key, audience and claim set, so without this either one verifies as the
160
+ * other: an access token — sent on every request — could be redeemed for a
161
+ * refresh token, and a refresh token presented as a bearer credential.
162
+ * Absent from tokens issued before it existed; those are refused as both.
163
+ */
164
+ token_use?: "access" | "refresh";
157
165
  }
158
166
  /**
159
167
  * JWT Issuer configuration
@@ -24,7 +24,7 @@ import {
24
24
  requireAuth,
25
25
  requireRole,
26
26
  requireScopes
27
- } from "../chunk-76HUSLES.js";
27
+ } from "../chunk-ZVK5GKEO.js";
28
28
  export {
29
29
  AuthProvider,
30
30
  AzureProvider,
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkNLFL6ISLcjs = require('./chunk-NLFL6ISL.cjs');
3
+ var _chunkPNWCRGJYcjs = require('./chunk-PNWCRGJY.cjs');
4
4
 
5
5
 
6
6
 
@@ -106,6 +106,27 @@ var noStore = {
106
106
  "Cache-Control": "no-store",
107
107
  Pragma: "no-cache"
108
108
  };
109
+ var invalidClientHeaders = {
110
+ ...noStore,
111
+ "WWW-Authenticate": 'Basic realm="oauth", charset="UTF-8"'
112
+ };
113
+ var parseBasicCredentials = (authorization) => {
114
+ const decoded = Buffer.from(authorization.slice(6).trim(), "base64").toString(
115
+ "utf8"
116
+ );
117
+ const separator = decoded.indexOf(":");
118
+ if (separator <= 0) {
119
+ return null;
120
+ }
121
+ try {
122
+ return {
123
+ clientId: decodeURIComponent(decoded.slice(0, separator)),
124
+ clientSecret: decodeURIComponent(decoded.slice(separator + 1))
125
+ };
126
+ } catch (e4) {
127
+ return null;
128
+ }
129
+ };
109
130
  var toSnakeCase = (value) => {
110
131
  if (!value || typeof value !== "object" || Array.isArray(value)) {
111
132
  return value;
@@ -173,21 +194,47 @@ var createOAuthRouter = (options) => {
173
194
  const params = Object.fromEntries(new URLSearchParams(text).entries());
174
195
  const authHeader = raw.headers.get("authorization");
175
196
  if (_optionalChain([authHeader, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4(), 'access', _5 => _5.startsWith, 'call', _6 => _6("basic ")])) {
176
- const decoded = Buffer.from(authHeader.slice(6), "base64").toString(
177
- "utf8"
178
- );
179
- const separator = decoded.indexOf(":");
180
- if (separator !== -1) {
181
- params.client_id ||= decodeURIComponent(decoded.slice(0, separator));
182
- params.client_secret ||= decodeURIComponent(
183
- decoded.slice(separator + 1)
197
+ const credentials = parseBasicCredentials(authHeader);
198
+ if (!credentials) {
199
+ return c.json(
200
+ {
201
+ error: "invalid_client",
202
+ error_description: "Malformed Basic Authorization header"
203
+ },
204
+ 401,
205
+ invalidClientHeaders
184
206
  );
185
207
  }
208
+ if (params.client_secret !== void 0) {
209
+ return c.json(
210
+ {
211
+ error: "invalid_request",
212
+ error_description: "Send client credentials in the Authorization header or the request body, not both"
213
+ },
214
+ 400,
215
+ noStore
216
+ );
217
+ }
218
+ if (params.client_id !== void 0 && params.client_id !== credentials.clientId) {
219
+ return c.json(
220
+ {
221
+ error: "invalid_request",
222
+ error_description: "client_id in the request body does not match the Authorization header"
223
+ },
224
+ 400,
225
+ noStore
226
+ );
227
+ }
228
+ params.client_id = credentials.clientId;
229
+ params.client_secret = credentials.clientSecret;
186
230
  }
187
231
  const result = params.grant_type === "refresh_token" ? await proxy.exchangeRefreshToken(params) : await proxy.exchangeAuthorizationCode(params);
188
232
  return c.json(result, 200, noStore);
189
233
  } catch (error) {
190
234
  const { body, status } = errorResponse(error);
235
+ if (body.error === "invalid_client") {
236
+ return c.json(body, 401, invalidClientHeaders);
237
+ }
191
238
  return c.json(body, status, noStore);
192
239
  }
193
240
  });
@@ -209,7 +256,7 @@ var cancelResponseBody = async (response) => {
209
256
  }
210
257
  try {
211
258
  await response.body.cancel();
212
- } catch (e4) {
259
+ } catch (e5) {
213
260
  }
214
261
  };
215
262
 
@@ -381,7 +428,7 @@ async function compileSchema(schema) {
381
428
  let ajvModule;
382
429
  try {
383
430
  ajvModule = dialect === "2020-12" ? await Promise.resolve().then(() => _interopRequireWildcard(require("ajv/dist/2020.js"))) : dialect === "2019-09" ? await Promise.resolve().then(() => _interopRequireWildcard(require("ajv/dist/2019.js"))) : await Promise.resolve().then(() => _interopRequireWildcard(require("ajv")));
384
- } catch (e5) {
431
+ } catch (e6) {
385
432
  throw new Error(
386
433
  'The "ajv" package is required to validate JSON Schema tool parameters. Install it with: npm install ajv'
387
434
  );
@@ -394,7 +441,7 @@ async function compileSchema(schema) {
394
441
  unwrapDefault(formatsModule)
395
442
  );
396
443
  addFormats(ajv);
397
- } catch (e6) {
444
+ } catch (e7) {
398
445
  }
399
446
  return ajv.compile(body);
400
447
  }
@@ -1412,7 +1459,7 @@ var withEndpointAsResource = (config, endpoint) => ({
1412
1459
  ...config,
1413
1460
  protectedResource: {
1414
1461
  ...config.protectedResource,
1415
- resource: `${_chunkNLFL6ISLcjs.withoutTrailingSlash.call(void 0, config.protectedResource.resource)}${endpoint}`
1462
+ resource: `${_chunkPNWCRGJYcjs.withoutTrailingSlash.call(void 0, config.protectedResource.resource)}${endpoint}`
1416
1463
  }
1417
1464
  });
1418
1465
  var nodeToWebRequest = (req, body, secure, signal) => {
@@ -1530,7 +1577,7 @@ var matchesOutputSchema = async (schema, value) => {
1530
1577
  value
1531
1578
  );
1532
1579
  return !result.issues;
1533
- } catch (e7) {
1580
+ } catch (e8) {
1534
1581
  return false;
1535
1582
  }
1536
1583
  };
@@ -1627,4 +1674,4 @@ var normalizeToolResult = (result, hasOutputSchema) => {
1627
1674
 
1628
1675
 
1629
1676
  exports.cancelResponseBody = cancelResponseBody; exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.delay = _promises5.setTimeout; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.ViteMCPError = ViteMCPError; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.ServerState = ServerState; exports.ViteMCP = ViteMCP;
1630
- //# sourceMappingURL=chunk-XU7XBDZI.cjs.map
1677
+ //# sourceMappingURL=chunk-2FAJF3V6.cjs.map