@vitemcp/server 1.10.2 → 1.10.4
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/dist/{OAuthProvider-STkC4R2N.d.cts → OAuthProvider-DbC_47_h.d.cts} +38 -5
- package/dist/{OAuthProvider-STkC4R2N.d.ts → OAuthProvider-DbC_47_h.d.ts} +38 -5
- package/dist/ViteMCP.cjs +4 -4
- package/dist/ViteMCP.d.cts +2 -2
- package/dist/ViteMCP.d.ts +2 -2
- package/dist/ViteMCP.js +3 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-NLBRDP5F.js → chunk-3QRGEISD.js} +113 -42
- package/dist/chunk-3QRGEISD.js.map +1 -0
- package/dist/{chunk-FSPSPB7Y.cjs → chunk-K2UCX3GS.cjs} +9 -9
- package/dist/{chunk-FSPSPB7Y.cjs.map → chunk-K2UCX3GS.cjs.map} +1 -1
- package/dist/{chunk-4LU4AXU4.cjs → chunk-LVPE26OW.cjs} +121 -50
- package/dist/chunk-LVPE26OW.cjs.map +1 -0
- package/dist/{chunk-3W6VP3KX.js → chunk-QYNWHXTM.js} +3 -3
- package/dist/{chunk-NZGRSB2D.cjs → chunk-R4RK2DR2.cjs} +147 -3
- package/dist/chunk-R4RK2DR2.cjs.map +1 -0
- package/dist/{chunk-BLXUZUZ4.js → chunk-YDEROYNS.js} +147 -3
- package/dist/chunk-YDEROYNS.js.map +1 -0
- package/dist/edge/index.cjs +6 -6
- package/dist/edge/index.js +1 -1
- package/dist/openapi/index.cjs +23 -16
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +3 -3
- package/dist/openapi/index.d.ts +3 -3
- package/dist/openapi/index.js +13 -6
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4LU4AXU4.cjs.map +0 -1
- package/dist/chunk-BLXUZUZ4.js.map +0 -1
- package/dist/chunk-NLBRDP5F.js.map +0 -1
- package/dist/chunk-NZGRSB2D.cjs.map +0 -1
- /package/dist/{chunk-3W6VP3KX.js.map → chunk-QYNWHXTM.js.map} +0 -0
|
@@ -299,7 +299,7 @@ interface OAuthProxyConfig {
|
|
|
299
299
|
* cannot be overridden — entries with those keys are ignored.
|
|
300
300
|
*/
|
|
301
301
|
extraAuthorizationParams?: Record<string, string>;
|
|
302
|
-
/** Forward client's PKCE to upstream (default: false) */
|
|
302
|
+
/** Forward the client's S256 PKCE to upstream (default: false) */
|
|
303
303
|
forwardPkce?: boolean;
|
|
304
304
|
/** Secret key for signing JWTs when token swap is enabled */
|
|
305
305
|
jwtSigningKey?: string;
|
|
@@ -311,7 +311,10 @@ interface OAuthProxyConfig {
|
|
|
311
311
|
scopes?: string[];
|
|
312
312
|
/** Custom token storage backend */
|
|
313
313
|
tokenStorage?: TokenStorage;
|
|
314
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* Verifies each access token the upstream issues, on code exchange and on
|
|
316
|
+
* refresh. A token it rejects is refused, and no tokens are issued for it.
|
|
317
|
+
*/
|
|
315
318
|
tokenVerifier?: TokenVerifier;
|
|
316
319
|
/** Transaction TTL in seconds (default: 600) */
|
|
317
320
|
transactionTtl?: number;
|
|
@@ -359,6 +362,8 @@ interface OAuthTransaction {
|
|
|
359
362
|
createdAt: Date;
|
|
360
363
|
/** Transaction expiration timestamp */
|
|
361
364
|
expiresAt: Date;
|
|
365
|
+
/** Whether the upstream authorization uses the client's S256 challenge */
|
|
366
|
+
forwardPkce?: true;
|
|
362
367
|
/** Unique transaction ID */
|
|
363
368
|
id: string;
|
|
364
369
|
/** Additional state data */
|
|
@@ -645,6 +650,19 @@ declare class OAuthProxy {
|
|
|
645
650
|
* Handle consent form submission
|
|
646
651
|
*/
|
|
647
652
|
handleConsent(request: Request): Promise<Response>;
|
|
653
|
+
/**
|
|
654
|
+
* What a ViteMCP access token stands for: the upstream tokens it maps to,
|
|
655
|
+
* and the custom claims it carries (see `customClaimsPassthrough`). `null`
|
|
656
|
+
* for any token `loadUpstreamTokens` refuses.
|
|
657
|
+
*
|
|
658
|
+
* One verification and one lookup give both. `authenticate` runs on every
|
|
659
|
+
* request, so loading the claims separately would verify the token and read
|
|
660
|
+
* its mapping again each time.
|
|
661
|
+
*/
|
|
662
|
+
loadAccessToken(vitemcpToken: string): Promise<{
|
|
663
|
+
claims?: Record<string, unknown>;
|
|
664
|
+
upstreamTokens: UpstreamTokenSet;
|
|
665
|
+
} | null>;
|
|
648
666
|
/**
|
|
649
667
|
* Load upstream tokens from a ViteMCP JWT
|
|
650
668
|
*/
|
|
@@ -929,6 +947,17 @@ declare class OAuthProxy {
|
|
|
929
947
|
* theft. Do not loosen the default beyond loopback addresses.
|
|
930
948
|
*/
|
|
931
949
|
private validateRedirectUri;
|
|
950
|
+
/**
|
|
951
|
+
* Runs the configured `tokenVerifier` over an access token the upstream has
|
|
952
|
+
* just issued, before it is stored or reaches a client. Accepted and never
|
|
953
|
+
* called, the option let through every token a server had set it to refuse.
|
|
954
|
+
*
|
|
955
|
+
* RFC 6749 names the refusal differently at each endpoint: `access_denied`
|
|
956
|
+
* for an authorization response (§4.1.2.1), `invalid_grant` for a token
|
|
957
|
+
* response (§5.2). The verifier's own reason is not passed on: it describes
|
|
958
|
+
* the token.
|
|
959
|
+
*/
|
|
960
|
+
private verifyUpstreamAccessToken;
|
|
932
961
|
}
|
|
933
962
|
declare class OAuthProxyError extends Error {
|
|
934
963
|
code: string;
|
|
@@ -1006,7 +1035,10 @@ interface GenericOAuthProviderConfig extends AuthProviderConfig {
|
|
|
1006
1035
|
interface OAuthSession {
|
|
1007
1036
|
/** The upstream OAuth access token */
|
|
1008
1037
|
accessToken: string;
|
|
1009
|
-
/**
|
|
1038
|
+
/**
|
|
1039
|
+
* Custom claims passed through from the upstream tokens (see
|
|
1040
|
+
* `customClaimsPassthrough`). Unset when there are none.
|
|
1041
|
+
*/
|
|
1010
1042
|
claims?: Record<string, unknown>;
|
|
1011
1043
|
/** Token expiration time (Unix timestamp in seconds) */
|
|
1012
1044
|
expiresAt?: number;
|
|
@@ -1083,10 +1115,11 @@ declare abstract class AuthProvider<TSession extends OAuthSession = OAuthSession
|
|
|
1083
1115
|
/** Create the underlying OAuthProxy with provider-specific configuration */
|
|
1084
1116
|
protected abstract createProxy(): OAuthProxy;
|
|
1085
1117
|
/**
|
|
1086
|
-
* Create a session object from upstream tokens
|
|
1118
|
+
* Create a session object from upstream tokens, and the custom claims the
|
|
1119
|
+
* caller's token carries.
|
|
1087
1120
|
* Override in subclasses to add provider-specific session data.
|
|
1088
1121
|
*/
|
|
1089
|
-
protected createSession(upstreamTokens: UpstreamTokenSet): TSession;
|
|
1122
|
+
protected createSession(upstreamTokens: UpstreamTokenSet, claims?: Record<string, unknown>): TSession;
|
|
1090
1123
|
/** Get the authorization endpoint for this provider */
|
|
1091
1124
|
protected abstract getAuthorizationEndpoint(): string;
|
|
1092
1125
|
/** Default scopes for this provider */
|
|
@@ -299,7 +299,7 @@ interface OAuthProxyConfig {
|
|
|
299
299
|
* cannot be overridden — entries with those keys are ignored.
|
|
300
300
|
*/
|
|
301
301
|
extraAuthorizationParams?: Record<string, string>;
|
|
302
|
-
/** Forward client's PKCE to upstream (default: false) */
|
|
302
|
+
/** Forward the client's S256 PKCE to upstream (default: false) */
|
|
303
303
|
forwardPkce?: boolean;
|
|
304
304
|
/** Secret key for signing JWTs when token swap is enabled */
|
|
305
305
|
jwtSigningKey?: string;
|
|
@@ -311,7 +311,10 @@ interface OAuthProxyConfig {
|
|
|
311
311
|
scopes?: string[];
|
|
312
312
|
/** Custom token storage backend */
|
|
313
313
|
tokenStorage?: TokenStorage;
|
|
314
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* Verifies each access token the upstream issues, on code exchange and on
|
|
316
|
+
* refresh. A token it rejects is refused, and no tokens are issued for it.
|
|
317
|
+
*/
|
|
315
318
|
tokenVerifier?: TokenVerifier;
|
|
316
319
|
/** Transaction TTL in seconds (default: 600) */
|
|
317
320
|
transactionTtl?: number;
|
|
@@ -359,6 +362,8 @@ interface OAuthTransaction {
|
|
|
359
362
|
createdAt: Date;
|
|
360
363
|
/** Transaction expiration timestamp */
|
|
361
364
|
expiresAt: Date;
|
|
365
|
+
/** Whether the upstream authorization uses the client's S256 challenge */
|
|
366
|
+
forwardPkce?: true;
|
|
362
367
|
/** Unique transaction ID */
|
|
363
368
|
id: string;
|
|
364
369
|
/** Additional state data */
|
|
@@ -645,6 +650,19 @@ declare class OAuthProxy {
|
|
|
645
650
|
* Handle consent form submission
|
|
646
651
|
*/
|
|
647
652
|
handleConsent(request: Request): Promise<Response>;
|
|
653
|
+
/**
|
|
654
|
+
* What a ViteMCP access token stands for: the upstream tokens it maps to,
|
|
655
|
+
* and the custom claims it carries (see `customClaimsPassthrough`). `null`
|
|
656
|
+
* for any token `loadUpstreamTokens` refuses.
|
|
657
|
+
*
|
|
658
|
+
* One verification and one lookup give both. `authenticate` runs on every
|
|
659
|
+
* request, so loading the claims separately would verify the token and read
|
|
660
|
+
* its mapping again each time.
|
|
661
|
+
*/
|
|
662
|
+
loadAccessToken(vitemcpToken: string): Promise<{
|
|
663
|
+
claims?: Record<string, unknown>;
|
|
664
|
+
upstreamTokens: UpstreamTokenSet;
|
|
665
|
+
} | null>;
|
|
648
666
|
/**
|
|
649
667
|
* Load upstream tokens from a ViteMCP JWT
|
|
650
668
|
*/
|
|
@@ -929,6 +947,17 @@ declare class OAuthProxy {
|
|
|
929
947
|
* theft. Do not loosen the default beyond loopback addresses.
|
|
930
948
|
*/
|
|
931
949
|
private validateRedirectUri;
|
|
950
|
+
/**
|
|
951
|
+
* Runs the configured `tokenVerifier` over an access token the upstream has
|
|
952
|
+
* just issued, before it is stored or reaches a client. Accepted and never
|
|
953
|
+
* called, the option let through every token a server had set it to refuse.
|
|
954
|
+
*
|
|
955
|
+
* RFC 6749 names the refusal differently at each endpoint: `access_denied`
|
|
956
|
+
* for an authorization response (§4.1.2.1), `invalid_grant` for a token
|
|
957
|
+
* response (§5.2). The verifier's own reason is not passed on: it describes
|
|
958
|
+
* the token.
|
|
959
|
+
*/
|
|
960
|
+
private verifyUpstreamAccessToken;
|
|
932
961
|
}
|
|
933
962
|
declare class OAuthProxyError extends Error {
|
|
934
963
|
code: string;
|
|
@@ -1006,7 +1035,10 @@ interface GenericOAuthProviderConfig extends AuthProviderConfig {
|
|
|
1006
1035
|
interface OAuthSession {
|
|
1007
1036
|
/** The upstream OAuth access token */
|
|
1008
1037
|
accessToken: string;
|
|
1009
|
-
/**
|
|
1038
|
+
/**
|
|
1039
|
+
* Custom claims passed through from the upstream tokens (see
|
|
1040
|
+
* `customClaimsPassthrough`). Unset when there are none.
|
|
1041
|
+
*/
|
|
1010
1042
|
claims?: Record<string, unknown>;
|
|
1011
1043
|
/** Token expiration time (Unix timestamp in seconds) */
|
|
1012
1044
|
expiresAt?: number;
|
|
@@ -1083,10 +1115,11 @@ declare abstract class AuthProvider<TSession extends OAuthSession = OAuthSession
|
|
|
1083
1115
|
/** Create the underlying OAuthProxy with provider-specific configuration */
|
|
1084
1116
|
protected abstract createProxy(): OAuthProxy;
|
|
1085
1117
|
/**
|
|
1086
|
-
* Create a session object from upstream tokens
|
|
1118
|
+
* Create a session object from upstream tokens, and the custom claims the
|
|
1119
|
+
* caller's token carries.
|
|
1087
1120
|
* Override in subclasses to add provider-specific session data.
|
|
1088
1121
|
*/
|
|
1089
|
-
protected createSession(upstreamTokens: UpstreamTokenSet): TSession;
|
|
1122
|
+
protected createSession(upstreamTokens: UpstreamTokenSet, claims?: Record<string, unknown>): TSession;
|
|
1090
1123
|
/** Get the authorization endpoint for this provider */
|
|
1091
1124
|
protected abstract getAuthorizationEndpoint(): string;
|
|
1092
1125
|
/** Default scopes for this provider */
|
package/dist/ViteMCP.cjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkK2UCX3GScjs = require('./chunk-K2UCX3GS.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -25,8 +25,8 @@ var _chunkFSPSPB7Ycjs = require('./chunk-FSPSPB7Y.cjs');
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
var
|
|
29
|
-
require('./chunk-
|
|
28
|
+
var _chunkLVPE26OWcjs = require('./chunk-LVPE26OW.cjs');
|
|
29
|
+
require('./chunk-R4RK2DR2.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
@@ -52,5 +52,5 @@ require('./chunk-NZGRSB2D.cjs');
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
exports.AuthProvider =
|
|
55
|
+
exports.AuthProvider = _chunkLVPE26OWcjs.AuthProvider; exports.AzureProvider = _chunkLVPE26OWcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkK2UCX3GScjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkLVPE26OWcjs.GitHubProvider; exports.GoogleProvider = _chunkLVPE26OWcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkK2UCX3GScjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkLVPE26OWcjs.OAuthProvider; exports.OAuthProxy = _chunkLVPE26OWcjs.OAuthProxy; exports.OAuthProxyError = _chunkLVPE26OWcjs.OAuthProxyError; exports.ServerState = _chunkK2UCX3GScjs.ServerState; exports.UnexpectedStateError = _chunkK2UCX3GScjs.UnexpectedStateError; exports.UserError = _chunkK2UCX3GScjs.UserError; exports.ViteMCP = _chunkK2UCX3GScjs.ViteMCP; exports.ViteMCPError = _chunkK2UCX3GScjs.ViteMCPError; exports.audioContent = _chunkK2UCX3GScjs.audioContent; exports.delay = _chunkK2UCX3GScjs.delay; exports.getAuthSession = _chunkLVPE26OWcjs.getAuthSession; exports.imageContent = _chunkK2UCX3GScjs.imageContent; exports.jsonSchemaAdapter = _chunkK2UCX3GScjs.jsonSchemaAdapter; exports.requireAll = _chunkLVPE26OWcjs.requireAll; exports.requireAny = _chunkLVPE26OWcjs.requireAny; exports.requireAuth = _chunkLVPE26OWcjs.requireAuth; exports.requireRole = _chunkLVPE26OWcjs.requireRole; exports.requireScopes = _chunkLVPE26OWcjs.requireScopes;
|
|
56
56
|
//# sourceMappingURL=ViteMCP.cjs.map
|
package/dist/ViteMCP.d.cts
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-
|
|
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-
|
|
7
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-DbC_47_h.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-DbC_47_h.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-
|
|
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-
|
|
7
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-DbC_47_h.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-DbC_47_h.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-
|
|
13
|
+
} from "./chunk-QYNWHXTM.js";
|
|
14
14
|
import {
|
|
15
15
|
AuthProvider,
|
|
16
16
|
AzureProvider,
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
requireAuth,
|
|
26
26
|
requireRole,
|
|
27
27
|
requireScopes
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-3QRGEISD.js";
|
|
29
|
+
import "./chunk-YDEROYNS.js";
|
|
30
30
|
export {
|
|
31
31
|
AuthProvider,
|
|
32
32
|
AzureProvider,
|
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkLVPE26OWcjs = require('../chunk-LVPE26OW.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -51,5 +51,5 @@ var _chunk4LU4AXU4cjs = require('../chunk-4LU4AXU4.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkLVPE26OWcjs.AuthProvider; exports.AzureProvider = _chunkLVPE26OWcjs.AzureProvider; exports.ConsentManager = _chunkLVPE26OWcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkLVPE26OWcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkLVPE26OWcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkLVPE26OWcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkLVPE26OWcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkLVPE26OWcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkLVPE26OWcjs.DiskStore; exports.EncryptedTokenStorage = _chunkLVPE26OWcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkLVPE26OWcjs.GitHubProvider; exports.GoogleProvider = _chunkLVPE26OWcjs.GoogleProvider; exports.JWKSVerifier = _chunkLVPE26OWcjs.JWKSVerifier; exports.JWTIssuer = _chunkLVPE26OWcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkLVPE26OWcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkLVPE26OWcjs.OAuthProvider; exports.OAuthProxy = _chunkLVPE26OWcjs.OAuthProxy; exports.OAuthProxyError = _chunkLVPE26OWcjs.OAuthProxyError; exports.PKCEUtils = _chunkLVPE26OWcjs.PKCEUtils; exports.getAuthSession = _chunkLVPE26OWcjs.getAuthSession; exports.requireAll = _chunkLVPE26OWcjs.requireAll; exports.requireAny = _chunkLVPE26OWcjs.requireAny; exports.requireAuth = _chunkLVPE26OWcjs.requireAuth; exports.requireRole = _chunkLVPE26OWcjs.requireRole; exports.requireScopes = _chunkLVPE26OWcjs.requireScopes;
|
|
55
55
|
//# sourceMappingURL=index.cjs.map
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -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-
|
|
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-
|
|
1
|
+
import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-DbC_47_h.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-DbC_47_h.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Consent Management
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
1
|
+
import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-DbC_47_h.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-DbC_47_h.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Consent Management
|
package/dist/auth/index.js
CHANGED
|
@@ -383,6 +383,17 @@ var clientCodeStorageSchema = z.object({
|
|
|
383
383
|
upstreamTokens: upstreamTokenSetStorageSchema,
|
|
384
384
|
used: z.boolean().optional()
|
|
385
385
|
});
|
|
386
|
+
var upstreamCodeStorageSchema = z.object({
|
|
387
|
+
code: z.string().min(1),
|
|
388
|
+
scope: z.array(z.string())
|
|
389
|
+
});
|
|
390
|
+
var storedClientCodeSchema = z.union([
|
|
391
|
+
clientCodeStorageSchema,
|
|
392
|
+
clientCodeStorageSchema.omit({ upstreamTokens: true }).extend({
|
|
393
|
+
codeChallenge: z.string().min(1),
|
|
394
|
+
upstreamCode: upstreamCodeStorageSchema
|
|
395
|
+
}).refine(({ codeChallengeMethod }) => codeChallengeMethod === "S256")
|
|
396
|
+
]);
|
|
386
397
|
var spentClientCodeStorageSchema = z.object({
|
|
387
398
|
expiresAt: storedDateSchema,
|
|
388
399
|
used: z.literal(true)
|
|
@@ -396,6 +407,7 @@ var oauthTransactionStorageSchema = z.object({
|
|
|
396
407
|
consentGiven: z.boolean().optional(),
|
|
397
408
|
createdAt: storedDateSchema,
|
|
398
409
|
expiresAt: storedDateSchema,
|
|
410
|
+
forwardPkce: z.literal(true).optional(),
|
|
399
411
|
id: z.string(),
|
|
400
412
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
401
413
|
proxyCodeChallenge: z.string(),
|
|
@@ -433,7 +445,7 @@ var OAuthProxyStateStore = class {
|
|
|
433
445
|
if (spent.success) {
|
|
434
446
|
return this.isExpired(spent.data.expiresAt) ? null : { expiresAt: spent.data.expiresAt, status: "spent" };
|
|
435
447
|
}
|
|
436
|
-
const parsed =
|
|
448
|
+
const parsed = storedClientCodeSchema.safeParse(stored);
|
|
437
449
|
if (!parsed.success || this.isExpired(parsed.data.expiresAt)) {
|
|
438
450
|
return null;
|
|
439
451
|
}
|
|
@@ -594,6 +606,17 @@ var ClaimsExtractor = class {
|
|
|
594
606
|
maxClaimValueSize: config.maxClaimValueSize || 2e3
|
|
595
607
|
};
|
|
596
608
|
}
|
|
609
|
+
/**
|
|
610
|
+
* The claims of a token this proxy issued that came from upstream: all but
|
|
611
|
+
* its own, which are the ones never copied from upstream. `null` when there
|
|
612
|
+
* are none — an opaque upstream token, or passthrough found nothing.
|
|
613
|
+
*/
|
|
614
|
+
customClaimsOf(tokenClaims) {
|
|
615
|
+
const custom = Object.entries(tokenClaims).filter(
|
|
616
|
+
([key]) => !this.PROTECTED_CLAIMS.has(key)
|
|
617
|
+
);
|
|
618
|
+
return custom.length > 0 ? Object.fromEntries(custom) : null;
|
|
619
|
+
}
|
|
597
620
|
/**
|
|
598
621
|
* Extract claims from a token (access token or ID token)
|
|
599
622
|
*/
|
|
@@ -1733,52 +1756,57 @@ var OAuthProxy = class {
|
|
|
1733
1756
|
`S256 PKCE is required for ${describeUnauthenticatedClient(client)}`
|
|
1734
1757
|
);
|
|
1735
1758
|
}
|
|
1759
|
+
const codeVerifier = request2.code_verifier;
|
|
1736
1760
|
if (clientCode.codeChallenge) {
|
|
1737
|
-
if (!
|
|
1761
|
+
if (!codeVerifier) {
|
|
1738
1762
|
throw new OAuthProxyError(
|
|
1739
1763
|
"invalid_request",
|
|
1740
1764
|
"code_verifier required for PKCE"
|
|
1741
1765
|
);
|
|
1742
1766
|
}
|
|
1743
1767
|
const valid = PKCEUtils.validateChallenge(
|
|
1744
|
-
|
|
1768
|
+
codeVerifier,
|
|
1745
1769
|
clientCode.codeChallenge,
|
|
1746
1770
|
clientCode.codeChallengeMethod
|
|
1747
1771
|
);
|
|
1748
1772
|
if (!valid) {
|
|
1749
1773
|
throw new OAuthProxyError("invalid_grant", "Invalid PKCE verifier");
|
|
1750
1774
|
}
|
|
1751
|
-
} else if (
|
|
1775
|
+
} else if (codeVerifier) {
|
|
1752
1776
|
throw new OAuthProxyError(
|
|
1753
1777
|
"invalid_request",
|
|
1754
1778
|
"code_verifier provided without a code_challenge"
|
|
1755
1779
|
);
|
|
1756
1780
|
}
|
|
1781
|
+
const upstreamTokens = "upstreamTokens" in clientCode ? clientCode.upstreamTokens : await this.exchangeUpstreamCode(clientCode.upstreamCode.code, {
|
|
1782
|
+
clientCodeVerifier: codeVerifier,
|
|
1783
|
+
scope: clientCode.upstreamCode.scope
|
|
1784
|
+
});
|
|
1757
1785
|
if (this.config.enableTokenSwap && this.jwtIssuer) {
|
|
1758
1786
|
return await this.issueSwappedTokens(
|
|
1759
1787
|
clientCode.clientId,
|
|
1760
|
-
|
|
1788
|
+
upstreamTokens,
|
|
1761
1789
|
authenticated
|
|
1762
1790
|
);
|
|
1763
1791
|
} else {
|
|
1764
1792
|
const response = {
|
|
1765
|
-
access_token:
|
|
1766
|
-
expires_in:
|
|
1767
|
-
token_type:
|
|
1793
|
+
access_token: upstreamTokens.accessToken,
|
|
1794
|
+
expires_in: upstreamTokens.expiresIn || 3600,
|
|
1795
|
+
token_type: upstreamTokens.tokenType
|
|
1768
1796
|
};
|
|
1769
|
-
if (
|
|
1797
|
+
if (upstreamTokens.refreshToken) {
|
|
1770
1798
|
await this.savePassthroughRefreshBinding(
|
|
1771
|
-
|
|
1799
|
+
upstreamTokens.refreshToken,
|
|
1772
1800
|
{ clientAuthenticated: authenticated, clientId: client.clientId },
|
|
1773
|
-
|
|
1801
|
+
upstreamTokens.refreshExpiresIn
|
|
1774
1802
|
);
|
|
1775
|
-
response.refresh_token =
|
|
1803
|
+
response.refresh_token = upstreamTokens.refreshToken;
|
|
1776
1804
|
}
|
|
1777
|
-
if (
|
|
1778
|
-
response.id_token =
|
|
1805
|
+
if (upstreamTokens.idToken) {
|
|
1806
|
+
response.id_token = upstreamTokens.idToken;
|
|
1779
1807
|
}
|
|
1780
|
-
if (
|
|
1781
|
-
response.scope =
|
|
1808
|
+
if (upstreamTokens.scope.length > 0) {
|
|
1809
|
+
response.scope = upstreamTokens.scope.join(" ");
|
|
1782
1810
|
}
|
|
1783
1811
|
return response;
|
|
1784
1812
|
}
|
|
@@ -1882,10 +1910,9 @@ var OAuthProxy = class {
|
|
|
1882
1910
|
relayableError(error, description)
|
|
1883
1911
|
);
|
|
1884
1912
|
}
|
|
1885
|
-
const upstreamTokens = await this.exchangeUpstreamCode(code, transaction);
|
|
1886
1913
|
const clientCode = await this.generateAuthorizationCode(
|
|
1887
1914
|
transaction,
|
|
1888
|
-
|
|
1915
|
+
transaction.forwardPkce ? { code, scope: transaction.scope } : await this.exchangeUpstreamCode(code, transaction)
|
|
1889
1916
|
);
|
|
1890
1917
|
return this.redirectToClient(transaction, { code: clientCode });
|
|
1891
1918
|
}
|
|
@@ -1939,9 +1966,15 @@ var OAuthProxy = class {
|
|
|
1939
1966
|
return this.redirectToUpstream(approvedTransaction);
|
|
1940
1967
|
}
|
|
1941
1968
|
/**
|
|
1942
|
-
*
|
|
1969
|
+
* What a ViteMCP access token stands for: the upstream tokens it maps to,
|
|
1970
|
+
* and the custom claims it carries (see `customClaimsPassthrough`). `null`
|
|
1971
|
+
* for any token `loadUpstreamTokens` refuses.
|
|
1972
|
+
*
|
|
1973
|
+
* One verification and one lookup give both. `authenticate` runs on every
|
|
1974
|
+
* request, so loading the claims separately would verify the token and read
|
|
1975
|
+
* its mapping again each time.
|
|
1943
1976
|
*/
|
|
1944
|
-
async
|
|
1977
|
+
async loadAccessToken(vitemcpToken) {
|
|
1945
1978
|
if (!this.jwtIssuer) {
|
|
1946
1979
|
return null;
|
|
1947
1980
|
}
|
|
@@ -1961,7 +1994,17 @@ var OAuthProxy = class {
|
|
|
1961
1994
|
const upstreamTokens = await this.tokenStorage.get(
|
|
1962
1995
|
`upstream:${this.issuerNs}:${mapping.upstreamTokenKey}`
|
|
1963
1996
|
);
|
|
1964
|
-
|
|
1997
|
+
if (!upstreamTokens) {
|
|
1998
|
+
return null;
|
|
1999
|
+
}
|
|
2000
|
+
const claims = this.claimsExtractor?.customClaimsOf(result.claims);
|
|
2001
|
+
return { ...claims ? { claims } : {}, upstreamTokens };
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Load upstream tokens from a ViteMCP JWT
|
|
2005
|
+
*/
|
|
2006
|
+
async loadUpstreamTokens(vitemcpToken) {
|
|
2007
|
+
return (await this.loadAccessToken(vitemcpToken))?.upstreamTokens ?? null;
|
|
1965
2008
|
}
|
|
1966
2009
|
/**
|
|
1967
2010
|
* RFC 7591 Dynamic Client Registration
|
|
@@ -2167,6 +2210,7 @@ var OAuthProxy = class {
|
|
|
2167
2210
|
expiresAt: new Date(
|
|
2168
2211
|
Date.now() + (this.config.transactionTtl || 600) * 1e3
|
|
2169
2212
|
),
|
|
2213
|
+
...this.config.forwardPkce && params.code_challenge && params.code_challenge_method === "S256" && { forwardPkce: true },
|
|
2170
2214
|
id: transactionId,
|
|
2171
2215
|
proxyCodeChallenge: proxyPkce.challenge,
|
|
2172
2216
|
proxyCodeVerifier: proxyPkce.verifier,
|
|
@@ -2180,11 +2224,12 @@ var OAuthProxy = class {
|
|
|
2180
2224
|
/**
|
|
2181
2225
|
* Exchange authorization code with upstream provider
|
|
2182
2226
|
*/
|
|
2183
|
-
async exchangeUpstreamCode(code,
|
|
2227
|
+
async exchangeUpstreamCode(code, exchange) {
|
|
2228
|
+
const forwardsPkce = "clientCodeVerifier" in exchange;
|
|
2184
2229
|
const useBasicAuth = this.config.upstreamTokenEndpointAuthMethod === "client_secret_basic";
|
|
2185
2230
|
const bodyParams = {
|
|
2186
2231
|
code,
|
|
2187
|
-
code_verifier:
|
|
2232
|
+
code_verifier: forwardsPkce ? exchange.clientCodeVerifier : exchange.proxyCodeVerifier,
|
|
2188
2233
|
grant_type: "authorization_code",
|
|
2189
2234
|
redirect_uri: `${this.config.baseUrl}${this.getRedirectPath()}`
|
|
2190
2235
|
};
|
|
@@ -2212,6 +2257,10 @@ var OAuthProxy = class {
|
|
|
2212
2257
|
throw new OAuthProxyError(errorCode, errorDescription);
|
|
2213
2258
|
}
|
|
2214
2259
|
const tokens = await this.parseTokenResponse(tokenResponse);
|
|
2260
|
+
await this.verifyUpstreamAccessToken(
|
|
2261
|
+
tokens.access_token,
|
|
2262
|
+
forwardsPkce ? "invalid_grant" : "access_denied"
|
|
2263
|
+
);
|
|
2215
2264
|
return {
|
|
2216
2265
|
accessToken: tokens.access_token,
|
|
2217
2266
|
// 0 when the upstream did not say, so `accessTokenTtl` and the defaults
|
|
@@ -2222,7 +2271,7 @@ var OAuthProxy = class {
|
|
|
2222
2271
|
issuedAt: /* @__PURE__ */ new Date(),
|
|
2223
2272
|
refreshExpiresIn: tokens.refresh_expires_in,
|
|
2224
2273
|
refreshToken: tokens.refresh_token,
|
|
2225
|
-
scope: tokens.scope ? tokens.scope.split(" ") :
|
|
2274
|
+
scope: tokens.scope ? tokens.scope.split(" ") : exchange.scope,
|
|
2226
2275
|
tokenType: tokens.token_type || "Bearer"
|
|
2227
2276
|
};
|
|
2228
2277
|
}
|
|
@@ -2298,9 +2347,9 @@ var OAuthProxy = class {
|
|
|
2298
2347
|
/**
|
|
2299
2348
|
* Generate authorization code for client
|
|
2300
2349
|
*/
|
|
2301
|
-
async generateAuthorizationCode(transaction,
|
|
2350
|
+
async generateAuthorizationCode(transaction, upstream) {
|
|
2302
2351
|
const code = this.generateId();
|
|
2303
|
-
|
|
2352
|
+
await this.stateStore.saveClientCode({
|
|
2304
2353
|
clientId: transaction.clientId,
|
|
2305
2354
|
code,
|
|
2306
2355
|
codeChallenge: transaction.clientCodeChallenge,
|
|
@@ -2311,9 +2360,8 @@ var OAuthProxy = class {
|
|
|
2311
2360
|
),
|
|
2312
2361
|
redirectUri: transaction.clientCallbackUrl,
|
|
2313
2362
|
transactionId: transaction.id,
|
|
2314
|
-
upstreamTokens
|
|
2315
|
-
};
|
|
2316
|
-
await this.stateStore.saveClientCode(clientCode);
|
|
2363
|
+
..."accessToken" in upstream ? { upstreamTokens: upstream } : { upstreamCode: upstream }
|
|
2364
|
+
});
|
|
2317
2365
|
return code;
|
|
2318
2366
|
}
|
|
2319
2367
|
/**
|
|
@@ -2416,6 +2464,7 @@ var OAuthProxy = class {
|
|
|
2416
2464
|
throw new OAuthProxyError(errorCode, errorDescription);
|
|
2417
2465
|
}
|
|
2418
2466
|
const tokens = await this.parseTokenResponse(tokenResponse);
|
|
2467
|
+
await this.verifyUpstreamAccessToken(tokens.access_token, "invalid_grant");
|
|
2419
2468
|
await this.savePassthroughRefreshBinding(
|
|
2420
2469
|
tokens.refresh_token || request2.refresh_token,
|
|
2421
2470
|
{
|
|
@@ -2888,13 +2937,11 @@ var OAuthProxy = class {
|
|
|
2888
2937
|
if (transaction.scope.length > 0) {
|
|
2889
2938
|
authUrl.searchParams.set("scope", transaction.scope.join(" "));
|
|
2890
2939
|
}
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
2897
|
-
}
|
|
2940
|
+
authUrl.searchParams.set(
|
|
2941
|
+
"code_challenge",
|
|
2942
|
+
transaction.forwardPkce ? transaction.clientCodeChallenge : transaction.proxyCodeChallenge
|
|
2943
|
+
);
|
|
2944
|
+
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
2898
2945
|
return new Response(null, {
|
|
2899
2946
|
headers: {
|
|
2900
2947
|
Location: authUrl.toString()
|
|
@@ -2936,6 +2983,7 @@ var OAuthProxy = class {
|
|
|
2936
2983
|
throw new OAuthProxyError(errorCode, errorDescription);
|
|
2937
2984
|
}
|
|
2938
2985
|
const tokens = await this.parseTokenResponse(tokenResponse);
|
|
2986
|
+
await this.verifyUpstreamAccessToken(tokens.access_token, "invalid_grant");
|
|
2939
2987
|
return {
|
|
2940
2988
|
accessToken: tokens.access_token,
|
|
2941
2989
|
// 0 when the upstream did not say, as on the code exchange.
|
|
@@ -3138,6 +3186,25 @@ var OAuthProxy = class {
|
|
|
3138
3186
|
(pattern) => this.matchesPattern(url, pattern)
|
|
3139
3187
|
);
|
|
3140
3188
|
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Runs the configured `tokenVerifier` over an access token the upstream has
|
|
3191
|
+
* just issued, before it is stored or reaches a client. Accepted and never
|
|
3192
|
+
* called, the option let through every token a server had set it to refuse.
|
|
3193
|
+
*
|
|
3194
|
+
* RFC 6749 names the refusal differently at each endpoint: `access_denied`
|
|
3195
|
+
* for an authorization response (§4.1.2.1), `invalid_grant` for a token
|
|
3196
|
+
* response (§5.2). The verifier's own reason is not passed on: it describes
|
|
3197
|
+
* the token.
|
|
3198
|
+
*/
|
|
3199
|
+
async verifyUpstreamAccessToken(accessToken, errorCode) {
|
|
3200
|
+
const result = await this.config.tokenVerifier?.verify(accessToken);
|
|
3201
|
+
if (result && !result.valid) {
|
|
3202
|
+
throw new OAuthProxyError(
|
|
3203
|
+
errorCode,
|
|
3204
|
+
"Upstream access token failed verification"
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3141
3208
|
};
|
|
3142
3209
|
var globComponent = (glob) => {
|
|
3143
3210
|
const source = glob.replace(/[.*+?^${}()|[\]\\]/g, (character) => {
|
|
@@ -3275,11 +3342,11 @@ var AuthProvider = class {
|
|
|
3275
3342
|
if (!token) {
|
|
3276
3343
|
return void 0;
|
|
3277
3344
|
}
|
|
3278
|
-
const
|
|
3279
|
-
if (!
|
|
3345
|
+
const loaded = await this.proxy.loadAccessToken(token);
|
|
3346
|
+
if (!loaded) {
|
|
3280
3347
|
return void 0;
|
|
3281
3348
|
}
|
|
3282
|
-
return this.createSession(upstreamTokens);
|
|
3349
|
+
return this.createSession(loaded.upstreamTokens, loaded.claims);
|
|
3283
3350
|
}
|
|
3284
3351
|
/**
|
|
3285
3352
|
* Release the resources held by the proxy this provider built for itself.
|
|
@@ -3325,13 +3392,17 @@ var AuthProvider = class {
|
|
|
3325
3392
|
return this.proxy;
|
|
3326
3393
|
}
|
|
3327
3394
|
/**
|
|
3328
|
-
* Create a session object from upstream tokens
|
|
3395
|
+
* Create a session object from upstream tokens, and the custom claims the
|
|
3396
|
+
* caller's token carries.
|
|
3329
3397
|
* Override in subclasses to add provider-specific session data.
|
|
3330
3398
|
*/
|
|
3331
|
-
createSession(upstreamTokens) {
|
|
3399
|
+
createSession(upstreamTokens, claims) {
|
|
3332
3400
|
const issuedAt = new Date(upstreamTokens.issuedAt).getTime() || Date.now();
|
|
3333
3401
|
return {
|
|
3334
3402
|
accessToken: upstreamTokens.accessToken,
|
|
3403
|
+
// Typed and documented, and never set: a `canAccess` reading a role
|
|
3404
|
+
// from it, as the guide's own example does, refused everyone.
|
|
3405
|
+
...claims ? { claims } : {},
|
|
3335
3406
|
expiresAt: upstreamTokens.expiresIn ? Math.floor(issuedAt / 1e3) + upstreamTokens.expiresIn : void 0,
|
|
3336
3407
|
idToken: upstreamTokens.idToken,
|
|
3337
3408
|
refreshToken: upstreamTokens.refreshToken,
|
|
@@ -3919,4 +3990,4 @@ export {
|
|
|
3919
3990
|
DiskStore,
|
|
3920
3991
|
JWKSVerifier
|
|
3921
3992
|
};
|
|
3922
|
-
//# sourceMappingURL=chunk-
|
|
3993
|
+
//# sourceMappingURL=chunk-3QRGEISD.js.map
|