@mcp-z/oauth-microsoft 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/cjs/index.d.cts +16 -0
- package/dist/cjs/index.d.ts +16 -0
- package/dist/cjs/index.js +112 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/dcr-router.d.cts +44 -0
- package/dist/cjs/lib/dcr-router.d.ts +44 -0
- package/dist/cjs/lib/dcr-router.js +1227 -0
- package/dist/cjs/lib/dcr-router.js.map +1 -0
- package/dist/cjs/lib/dcr-utils.d.cts +160 -0
- package/dist/cjs/lib/dcr-utils.d.ts +160 -0
- package/dist/cjs/lib/dcr-utils.js +860 -0
- package/dist/cjs/lib/dcr-utils.js.map +1 -0
- package/dist/cjs/lib/dcr-verify.d.cts +53 -0
- package/dist/cjs/lib/dcr-verify.d.ts +53 -0
- package/dist/cjs/lib/dcr-verify.js +193 -0
- package/dist/cjs/lib/dcr-verify.js.map +1 -0
- package/dist/cjs/lib/fetch-with-timeout.d.cts +14 -0
- package/dist/cjs/lib/fetch-with-timeout.d.ts +14 -0
- package/dist/cjs/lib/fetch-with-timeout.js +257 -0
- package/dist/cjs/lib/fetch-with-timeout.js.map +1 -0
- package/dist/cjs/lib/token-verifier.d.cts +44 -0
- package/dist/cjs/lib/token-verifier.d.ts +44 -0
- package/dist/cjs/lib/token-verifier.js +253 -0
- package/dist/cjs/lib/token-verifier.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/providers/dcr.d.cts +110 -0
- package/dist/cjs/providers/dcr.d.ts +110 -0
- package/dist/cjs/providers/dcr.js +600 -0
- package/dist/cjs/providers/dcr.js.map +1 -0
- package/dist/cjs/providers/device-code.d.cts +179 -0
- package/dist/cjs/providers/device-code.d.ts +179 -0
- package/dist/cjs/providers/device-code.js +896 -0
- package/dist/cjs/providers/device-code.js.map +1 -0
- package/dist/cjs/providers/loopback-oauth.d.cts +125 -0
- package/dist/cjs/providers/loopback-oauth.d.ts +125 -0
- package/dist/cjs/providers/loopback-oauth.js +1325 -0
- package/dist/cjs/providers/loopback-oauth.js.map +1 -0
- package/dist/cjs/schemas/index.d.cts +20 -0
- package/dist/cjs/schemas/index.d.ts +20 -0
- package/dist/cjs/schemas/index.js +37 -0
- package/dist/cjs/schemas/index.js.map +1 -0
- package/dist/cjs/setup/config.d.cts +113 -0
- package/dist/cjs/setup/config.d.ts +113 -0
- package/dist/cjs/setup/config.js +246 -0
- package/dist/cjs/setup/config.js.map +1 -0
- package/dist/cjs/types.d.cts +188 -0
- package/dist/cjs/types.d.ts +188 -0
- package/dist/cjs/types.js +18 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/dcr-router.d.ts +44 -0
- package/dist/esm/lib/dcr-router.js +556 -0
- package/dist/esm/lib/dcr-router.js.map +1 -0
- package/dist/esm/lib/dcr-utils.d.ts +160 -0
- package/dist/esm/lib/dcr-utils.js +270 -0
- package/dist/esm/lib/dcr-utils.js.map +1 -0
- package/dist/esm/lib/dcr-verify.d.ts +53 -0
- package/dist/esm/lib/dcr-verify.js +53 -0
- package/dist/esm/lib/dcr-verify.js.map +1 -0
- package/dist/esm/lib/fetch-with-timeout.d.ts +14 -0
- package/dist/esm/lib/fetch-with-timeout.js +30 -0
- package/dist/esm/lib/fetch-with-timeout.js.map +1 -0
- package/dist/esm/lib/token-verifier.d.ts +44 -0
- package/dist/esm/lib/token-verifier.js +53 -0
- package/dist/esm/lib/token-verifier.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/providers/dcr.d.ts +110 -0
- package/dist/esm/providers/dcr.js +235 -0
- package/dist/esm/providers/dcr.js.map +1 -0
- package/dist/esm/providers/device-code.d.ts +179 -0
- package/dist/esm/providers/device-code.js +417 -0
- package/dist/esm/providers/device-code.js.map +1 -0
- package/dist/esm/providers/loopback-oauth.d.ts +125 -0
- package/dist/esm/providers/loopback-oauth.js +643 -0
- package/dist/esm/providers/loopback-oauth.js.map +1 -0
- package/dist/esm/schemas/index.d.ts +20 -0
- package/dist/esm/schemas/index.js +18 -0
- package/dist/esm/schemas/index.js.map +1 -0
- package/dist/esm/setup/config.d.ts +113 -0
- package/dist/esm/setup/config.js +268 -0
- package/dist/esm/setup/config.js.map +1 -0
- package/dist/esm/types.d.ts +188 -0
- package/dist/esm/types.js +8 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/oauth/oauth-microsoft/src/lib/dcr-router.ts"],"sourcesContent":["/**\n * DCR Router - OAuth 2.0 Authorization Server\n *\n * Implements OAuth 2.0 Dynamic Client Registration Protocol (RFC 7591)\n * and OAuth 2.0 Authorization Server endpoints (RFC 6749, RFC 8414, RFC 9728).\n *\n * Endpoints:\n * - GET /.well-known/oauth-authorization-server (RFC 8414 metadata)\n * - GET /.well-known/oauth-protected-resource (RFC 9728 metadata - root)\n * - GET /.well-known/oauth-protected-resource/mcp (RFC 9728 metadata - sub-path)\n * - POST /oauth/register (RFC 7591 client registration)\n * - GET /oauth/authorize (RFC 6749 authorization endpoint)\n * - POST /oauth/token (RFC 6749 token endpoint)\n * - POST /oauth/revoke (RFC 7009 token revocation)\n * - GET /oauth/verify (token verification for Resource Server)\n */\n\nimport type { ProviderTokens, RFC8414Metadata, RFC9728Metadata } from '@mcp-z/oauth';\nimport { createHash, randomUUID } from 'crypto';\nimport type { Request, Response } from 'express';\nimport express from 'express';\nimport type { Keyv } from 'keyv';\nimport { DcrOAuthProvider } from '../providers/dcr.ts';\nimport type { AccessToken, AuthorizationCode, OAuthClientConfig } from '../types.ts';\nimport * as dcrUtils from './dcr-utils.ts';\n\n/**\n * Configuration for DCR Router (self-hosted mode only)\n */\nexport interface DcrRouterConfig {\n /** Single Keyv store for all DCR data */\n store: Keyv;\n\n /** Authorization Server issuer URL */\n issuerUrl: string;\n\n /** Base URL for OAuth endpoints */\n baseUrl: string;\n\n /** Supported OAuth scopes */\n scopesSupported: string[];\n\n /** OAuth client configuration for upstream provider */\n clientConfig: OAuthClientConfig;\n}\n\n/**\n * Create DCR Router with OAuth 2.0 endpoints (self-hosted mode)\n *\n * For external mode (Auth0/Stitch), don't call this function - no router needed.\n * The server code should check DcrConfig.mode and only call this for 'self-hosted'.\n *\n * @param config - Router configuration\n * @returns Express router with OAuth endpoints\n */\nexport function createDcrRouter(config: DcrRouterConfig): express.Router {\n const router = express.Router();\n const { store, issuerUrl, baseUrl, scopesSupported, clientConfig } = config;\n\n // Apply required middleware for OAuth 2.0 endpoints (RFC 6749)\n router.use(express.json()); // For /oauth/register (application/json)\n router.use(express.urlencoded({ extended: true })); // For /oauth/token (application/x-www-form-urlencoded)\n\n /**\n * OAuth Authorization Server Metadata (RFC 8414)\n * GET /.well-known/oauth-authorization-server\n */\n router.get('/.well-known/oauth-authorization-server', (_req: Request, res: Response) => {\n const metadata: RFC8414Metadata = {\n issuer: issuerUrl,\n authorization_endpoint: `${baseUrl}/oauth/authorize`,\n token_endpoint: `${baseUrl}/oauth/token`,\n registration_endpoint: `${baseUrl}/oauth/register`,\n revocation_endpoint: `${baseUrl}/oauth/revoke`,\n scopes_supported: scopesSupported,\n response_types_supported: ['code'],\n grant_types_supported: ['authorization_code', 'refresh_token'],\n token_endpoint_auth_methods_supported: ['client_secret_basic', 'client_secret_post'],\n code_challenge_methods_supported: ['S256', 'plain'],\n service_documentation: `${baseUrl}/docs`,\n };\n res.json(metadata);\n });\n\n /**\n * OAuth Protected Resource Metadata (RFC 9728 - Root)\n * GET /.well-known/oauth-protected-resource\n */\n router.get('/.well-known/oauth-protected-resource', (_req: Request, res: Response) => {\n const metadata: RFC9728Metadata = {\n resource: baseUrl,\n authorization_servers: [baseUrl],\n scopes_supported: scopesSupported,\n bearer_methods_supported: ['header'],\n };\n res.json(metadata);\n });\n\n /**\n * OAuth Protected Resource Metadata (RFC 9728 - Sub-path /mcp)\n * GET /.well-known/oauth-protected-resource/mcp\n */\n router.get('/.well-known/oauth-protected-resource/mcp', (_req: Request, res: Response) => {\n const metadata: RFC9728Metadata = {\n resource: `${baseUrl}/mcp`,\n authorization_servers: [baseUrl],\n scopes_supported: scopesSupported,\n bearer_methods_supported: ['header'],\n };\n res.json(metadata);\n });\n\n /**\n * Dynamic Client Registration (RFC 7591)\n * POST /oauth/register\n */\n router.post('/oauth/register', async (req: Request, res: Response) => {\n try {\n const registrationRequest = req.body;\n\n // Register the client\n const client = await dcrUtils.registerClient(store, registrationRequest);\n\n // Return client information (RFC 7591 Section 3.2.1)\n res.status(201).json(client);\n } catch (error) {\n res.status(400).json({\n error: 'invalid_client_metadata',\n error_description: error instanceof Error ? error.message : 'Invalid registration request',\n });\n }\n });\n\n /**\n * OAuth Authorization Endpoint (RFC 6749 Section 3.1)\n * GET /oauth/authorize\n *\n * Initiates Microsoft OAuth flow, then generates DCR authorization code\n */\n router.get('/oauth/authorize', async (req: Request, res: Response) => {\n const { response_type, client_id, redirect_uri, scope = '', state = '', code_challenge, code_challenge_method } = req.query;\n\n // Validate required parameters\n if (response_type !== 'code') {\n return res.status(400).json({\n error: 'unsupported_response_type',\n error_description: 'Only response_type=code is supported',\n });\n }\n\n if (!client_id || typeof client_id !== 'string') {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'client_id is required',\n });\n }\n\n if (!redirect_uri || typeof redirect_uri !== 'string') {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'redirect_uri is required',\n });\n }\n\n // Validate client\n const client = await dcrUtils.getClient(store, client_id);\n if (!client) {\n return res.status(400).json({\n error: 'invalid_client',\n error_description: 'Unknown client_id',\n });\n }\n\n // Validate redirect_uri\n const isValidRedirect = await dcrUtils.validateRedirectUri(store, client_id, redirect_uri);\n if (!isValidRedirect) {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'Invalid redirect_uri',\n });\n }\n\n // Store DCR request state for Microsoft OAuth callback\n const msState = randomUUID();\n const dcrRequestState = {\n client_id,\n redirect_uri,\n scope: typeof scope === 'string' ? scope : '',\n state: typeof state === 'string' ? state : undefined,\n code_challenge: typeof code_challenge === 'string' ? code_challenge : undefined,\n code_challenge_method: typeof code_challenge_method === 'string' ? code_challenge_method : undefined,\n created_at: Date.now(),\n expires_at: Date.now() + 600000, // 10 minutes\n };\n\n await store.set(`dcr:ms-state:${msState}`, dcrRequestState, 600000); // 10 min TTL\n\n // Build Microsoft authorization URL\n const msAuthUrl = new URL(`https://login.microsoftonline.com/${clientConfig.tenantId || 'common'}/oauth2/v2.0/authorize`);\n msAuthUrl.searchParams.set('client_id', clientConfig.clientId);\n msAuthUrl.searchParams.set('response_type', 'code');\n msAuthUrl.searchParams.set('redirect_uri', `${baseUrl}/oauth/callback`);\n msAuthUrl.searchParams.set('scope', typeof scope === 'string' ? scope : '');\n msAuthUrl.searchParams.set('state', msState);\n msAuthUrl.searchParams.set('response_mode', 'query');\n\n // Redirect user to Microsoft for authorization\n return res.redirect(msAuthUrl.toString());\n });\n\n /**\n * OAuth Callback Handler\n * GET /oauth/callback\n *\n * Handles callback from Microsoft after user authorization\n */\n router.get('/oauth/callback', async (req: Request, res: Response) => {\n const { code: msCode, state: msState, error, error_description } = req.query;\n\n // Handle Microsoft OAuth errors\n if (error) {\n return res.status(400).json({\n error,\n error_description: error_description || 'Microsoft OAuth authorization failed',\n });\n }\n\n if (!msCode || typeof msCode !== 'string') {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'Authorization code is required',\n });\n }\n\n if (!msState || typeof msState !== 'string') {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'State parameter is required',\n });\n }\n\n // Retrieve original DCR request state\n const dcrRequestState = await store.get(`dcr:ms-state:${msState}`);\n if (!dcrRequestState) {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'Invalid or expired state parameter',\n });\n }\n\n // Delete state (one-time use)\n await store.delete(`dcr:ms-state:${msState}`);\n\n // Exchange Microsoft authorization code for tokens\n try {\n const tokenUrl = `https://login.microsoftonline.com/${clientConfig.tenantId || 'common'}/oauth2/v2.0/token`;\n const tokenParams = new URLSearchParams({\n grant_type: 'authorization_code',\n code: msCode,\n client_id: clientConfig.clientId,\n redirect_uri: `${baseUrl}/oauth/callback`,\n scope: dcrRequestState.scope,\n });\n\n // Add client_secret if available (confidential client)\n if (clientConfig.clientSecret) {\n tokenParams.set('client_secret', clientConfig.clientSecret);\n }\n\n const tokenResponse = await fetch(tokenUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: tokenParams.toString(),\n });\n\n if (!tokenResponse.ok) {\n const errorData = (await tokenResponse.json()) as { error?: string; error_description?: string };\n throw new Error(`Microsoft token exchange failed: ${errorData.error_description || errorData.error}`);\n }\n\n const tokenData = (await tokenResponse.json()) as {\n access_token: string;\n refresh_token?: string;\n expires_in: number;\n scope: string;\n };\n\n // Create provider tokens from Microsoft response\n const providerTokens: ProviderTokens = {\n accessToken: tokenData.access_token,\n ...(tokenData.refresh_token && { refreshToken: tokenData.refresh_token }),\n expiresAt: Date.now() + tokenData.expires_in * 1000,\n scope: tokenData.scope,\n };\n\n // Generate DCR authorization code with real provider tokens\n const dcrCode = randomUUID();\n const authCode: AuthorizationCode = {\n code: dcrCode,\n client_id: dcrRequestState.client_id,\n redirect_uri: dcrRequestState.redirect_uri,\n scope: dcrRequestState.scope,\n ...(dcrRequestState.code_challenge && { code_challenge: dcrRequestState.code_challenge }),\n ...(dcrRequestState.code_challenge_method && { code_challenge_method: dcrRequestState.code_challenge_method }),\n providerTokens,\n created_at: Date.now(),\n expires_at: Date.now() + 600000, // 10 minutes\n };\n\n await dcrUtils.setAuthCode(store, dcrCode, authCode);\n\n // Redirect back to MCP client with DCR authorization code\n const clientRedirectUrl = new URL(dcrRequestState.redirect_uri);\n clientRedirectUrl.searchParams.set('code', dcrCode);\n if (dcrRequestState.state) {\n clientRedirectUrl.searchParams.set('state', dcrRequestState.state);\n }\n\n return res.redirect(clientRedirectUrl.toString());\n } catch (error) {\n return res.status(500).json({\n error: 'server_error',\n error_description: error instanceof Error ? error.message : 'Failed to exchange authorization code',\n });\n }\n });\n\n /**\n * OAuth Token Endpoint (RFC 6749 Section 3.2)\n * POST /oauth/token\n */\n router.post('/oauth/token', async (req: Request, res: Response) => {\n // Extract client credentials from either body or Basic Auth header\n let client_id = req.body.client_id;\n let client_secret = req.body.client_secret;\n\n // Support client_secret_basic authentication (RFC 6749 Section 2.3.1)\n const authHeader = req.headers.authorization;\n if (authHeader && authHeader.startsWith('Basic ')) {\n const base64Credentials = authHeader.substring(6);\n const credentials = Buffer.from(base64Credentials, 'base64').toString('utf-8');\n const [id, secret] = credentials.split(':');\n client_id = id;\n client_secret = secret;\n }\n\n const { grant_type, code, redirect_uri, refresh_token, code_verifier } = req.body;\n\n // Validate grant_type\n if (!grant_type) {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'grant_type is required',\n });\n }\n\n if (grant_type === 'authorization_code') {\n // Authorization Code Grant\n if (!code || !client_id || !redirect_uri) {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'code, client_id, and redirect_uri are required',\n });\n }\n\n // Validate client credentials\n const isValidClient = await dcrUtils.validateClient(store, client_id, client_secret ?? '');\n if (!isValidClient) {\n return res.status(401).json({\n error: 'invalid_client',\n error_description: 'Invalid client credentials',\n });\n }\n\n // Get authorization code\n const authCode = await dcrUtils.getAuthCode(store, code);\n if (!authCode) {\n return res.status(400).json({\n error: 'invalid_grant',\n error_description: 'Invalid or expired authorization code',\n });\n }\n\n // Validate authorization code\n if (authCode.client_id !== client_id || authCode.redirect_uri !== redirect_uri) {\n return res.status(400).json({\n error: 'invalid_grant',\n error_description: 'Authorization code mismatch',\n });\n }\n\n if (Date.now() > authCode.expires_at) {\n await dcrUtils.deleteAuthCode(store, code);\n return res.status(400).json({\n error: 'invalid_grant',\n error_description: 'Authorization code expired',\n });\n }\n\n // Validate PKCE if used\n if (authCode.code_challenge) {\n if (!code_verifier) {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'code_verifier is required for PKCE',\n });\n }\n\n // Validate code_verifier against code_challenge\n const method = authCode.code_challenge_method ?? 'plain';\n const computedChallenge = method === 'S256' ? createHash('sha256').update(code_verifier).digest('base64url') : code_verifier;\n\n if (computedChallenge !== authCode.code_challenge) {\n return res.status(400).json({\n error: 'invalid_grant',\n error_description: 'Invalid code_verifier',\n });\n }\n }\n\n // Delete authorization code (one-time use)\n await dcrUtils.deleteAuthCode(store, code);\n\n // Generate DCR access token\n const accessToken = randomUUID();\n const refreshTokenValue = randomUUID();\n\n const tokenData: AccessToken = {\n access_token: accessToken,\n token_type: 'Bearer',\n expires_in: 3600,\n refresh_token: refreshTokenValue,\n scope: authCode.scope,\n client_id,\n providerTokens: authCode.providerTokens,\n created_at: Date.now(),\n };\n\n await dcrUtils.setAccessToken(store, accessToken, tokenData);\n await dcrUtils.setRefreshToken(store, refreshTokenValue, tokenData);\n\n // Store provider tokens indexed by DCR access token\n await dcrUtils.setProviderTokens(store, accessToken, authCode.providerTokens);\n\n // Return token response\n return res.json({\n access_token: tokenData.access_token,\n token_type: tokenData.token_type,\n expires_in: tokenData.expires_in,\n refresh_token: tokenData.refresh_token,\n scope: tokenData.scope,\n });\n }\n if (grant_type === 'refresh_token') {\n // Refresh Token Grant\n if (!refresh_token || !client_id) {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'refresh_token and client_id are required',\n });\n }\n\n // Validate client credentials\n const isValidClient = await dcrUtils.validateClient(store, client_id, client_secret ?? '');\n if (!isValidClient) {\n return res.status(401).json({\n error: 'invalid_client',\n error_description: 'Invalid client credentials',\n });\n }\n\n // Get refresh token\n const tokenData = await dcrUtils.getRefreshToken(store, refresh_token);\n if (!tokenData || tokenData.client_id !== client_id) {\n return res.status(400).json({\n error: 'invalid_grant',\n error_description: 'Invalid refresh token',\n });\n }\n\n // Refresh provider tokens if available\n let refreshedProviderTokens = tokenData.providerTokens;\n if (tokenData.providerTokens.refreshToken) {\n try {\n // Create DcrOAuthProvider instance to refresh Microsoft tokens\n const provider = new DcrOAuthProvider({\n clientId: clientConfig.clientId,\n ...(clientConfig.clientSecret && { clientSecret: clientConfig.clientSecret }),\n tenantId: clientConfig.tenantId ?? 'common',\n scope: tokenData.scope,\n verifyEndpoint: `${baseUrl}/oauth/verify`,\n logger: {\n info: console.log,\n error: console.error,\n warn: console.warn,\n debug: () => {},\n },\n });\n\n // Refresh the Microsoft access token\n refreshedProviderTokens = await provider.refreshAccessToken(tokenData.providerTokens.refreshToken);\n } catch (error) {\n // If refresh fails, continue with existing tokens (they may still be valid)\n console.warn('Provider token refresh failed, using existing tokens:', error instanceof Error ? error.message : String(error));\n }\n }\n\n // Generate new DCR access token\n const newAccessToken = randomUUID();\n const newTokenData: AccessToken = {\n ...tokenData,\n access_token: newAccessToken,\n created_at: Date.now(),\n };\n\n await dcrUtils.setAccessToken(store, newAccessToken, newTokenData);\n\n // Store refreshed provider tokens indexed by new DCR access token\n await dcrUtils.setProviderTokens(store, newAccessToken, refreshedProviderTokens);\n\n return res.json({\n access_token: newTokenData.access_token,\n token_type: newTokenData.token_type,\n expires_in: newTokenData.expires_in,\n scope: newTokenData.scope,\n });\n }\n return res.status(400).json({\n error: 'unsupported_grant_type',\n error_description: 'Only authorization_code and refresh_token grants are supported',\n });\n });\n\n /**\n * OAuth Token Revocation (RFC 7009)\n * POST /oauth/revoke\n */\n router.post('/oauth/revoke', async (req: Request, res: Response) => {\n const { token, token_type_hint, client_id, client_secret } = req.body;\n\n if (!token) {\n return res.status(400).json({\n error: 'invalid_request',\n error_description: 'token is required',\n });\n }\n\n // Validate client if credentials provided\n if (client_id && client_secret) {\n const isValidClient = await dcrUtils.validateClient(store, client_id, client_secret);\n if (!isValidClient) {\n return res.status(401).json({\n error: 'invalid_client',\n error_description: 'Invalid client credentials',\n });\n }\n }\n\n // Revoke the token\n if (token_type_hint === 'refresh_token') {\n await dcrUtils.deleteRefreshToken(store, token);\n } else if (token_type_hint === 'access_token') {\n await dcrUtils.deleteAccessToken(store, token);\n await dcrUtils.deleteProviderTokens(store, token);\n } else {\n // No hint - try both\n await dcrUtils.deleteRefreshToken(store, token);\n await dcrUtils.deleteAccessToken(store, token);\n await dcrUtils.deleteProviderTokens(store, token);\n }\n\n // RFC 7009: Return 200 even if token not found\n return res.status(200).send();\n });\n\n /**\n * Token Verification Endpoint\n * GET /oauth/verify\n *\n * Validates bearer tokens for Resource Server.\n * Returns AuthInfo with provider tokens for stateless DCR pattern.\n */\n router.get('/oauth/verify', async (req: Request, res: Response) => {\n // Extract bearer token from Authorization header\n const authHeader = req.headers.authorization;\n\n if (!authHeader || !authHeader.startsWith('Bearer ')) {\n return res.status(401).json({\n error: 'invalid_request',\n error_description: 'Missing or invalid Authorization header',\n });\n }\n\n const token = authHeader.substring(7); // Remove 'Bearer ' prefix\n\n // Validate token exists in access tokens store\n const tokenData = await dcrUtils.getAccessToken(store, token);\n\n if (!tokenData) {\n return res.status(401).json({\n error: 'invalid_token',\n error_description: 'Unknown or expired access token',\n });\n }\n\n // Check if token is expired\n const now = Date.now();\n const expiresAt = tokenData.created_at + tokenData.expires_in * 1000;\n\n if (now > expiresAt) {\n // Remove expired token\n await dcrUtils.deleteAccessToken(store, token);\n await dcrUtils.deleteProviderTokens(store, token);\n return res.status(401).json({\n error: 'invalid_token',\n error_description: 'Access token has expired',\n });\n }\n\n // Return AuthInfo with provider tokens for stateless DCR\n const authInfo = {\n token,\n clientId: tokenData.client_id,\n scopes: tokenData.scope ? tokenData.scope.split(' ') : [],\n expiresAt,\n providerTokens: tokenData.providerTokens,\n };\n\n return res.json(authInfo);\n });\n\n /**\n * Debug endpoint to list registered clients (development only)\n */\n router.get('/debug/clients', async (_req: Request, res: Response) => {\n const clients = await dcrUtils.listClients(store);\n res.json(clients);\n });\n\n return router;\n}\n"],"names":["createDcrRouter","config","router","express","Router","store","issuerUrl","baseUrl","scopesSupported","clientConfig","use","json","urlencoded","extended","get","_req","res","metadata","issuer","authorization_endpoint","token_endpoint","registration_endpoint","revocation_endpoint","scopes_supported","response_types_supported","grant_types_supported","token_endpoint_auth_methods_supported","code_challenge_methods_supported","service_documentation","resource","authorization_servers","bearer_methods_supported","post","req","registrationRequest","client","error","body","dcrUtils","registerClient","status","error_description","Error","message","response_type","client_id","redirect_uri","scope","state","code_challenge","code_challenge_method","isValidRedirect","msState","dcrRequestState","msAuthUrl","query","getClient","validateRedirectUri","randomUUID","undefined","created_at","Date","now","expires_at","set","URL","tenantId","searchParams","clientId","redirect","toString","msCode","tokenUrl","tokenParams","tokenResponse","errorData","tokenData","providerTokens","dcrCode","authCode","clientRedirectUrl","code","delete","URLSearchParams","grant_type","clientSecret","fetch","method","headers","ok","accessToken","access_token","refresh_token","refreshToken","expiresAt","expires_in","setAuthCode","client_secret","authHeader","base64Credentials","credentials","id","secret","code_verifier","isValidClient","computedChallenge","refreshTokenValue","refreshedProviderTokens","provider","newAccessToken","newTokenData","authorization","startsWith","substring","Buffer","from","split","validateClient","getAuthCode","deleteAuthCode","createHash","update","digest","token_type","setAccessToken","setRefreshToken","setProviderTokens","getRefreshToken","DcrOAuthProvider","verifyEndpoint","logger","info","console","log","warn","debug","refreshAccessToken","String","token","token_type_hint","deleteRefreshToken","deleteAccessToken","deleteProviderTokens","send","authInfo","getAccessToken","scopes","clients","listClients"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;;;;+BAwCeA;;;eAAAA;;;sBArCuB;8DAEnB;qBAEa;kEAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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mB;4BACrB;;;wBAGF,yDAAyD;wBACnDuG,WAAW;4BACfN,OAAAA;4BACAtE,UAAUQ,UAAU/B,SAAS;4BAC7BqG,QAAQtE,UAAU7B,KAAK,GAAG6B,UAAU7B,KAAK,CAACqE,KAAK,CAAC;4BAChDtB,WAAAA;4BACAjB,gBAAgBD,UAAUC,cAAc;wBAC1C;wBAEA;;4BAAO7D,IAAIL,IAAI,CAACqI;;;;QAClB;;IAEA;;GAEC,GACD9I,OAAOY,GAAG,CAAC,kBAAkB,SAAOC,MAAeC;;gBAC3CmI;;;;wBAAU;;4BAAM7G,YAAS8G,WAAW,CAAC/I;;;wBAArC8I,UAAU;wBAChBnI,IAAIL,IAAI,CAACwI;;;;;;QACX;;IAEA,OAAOjJ;AACT"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DCR Storage Utilities
|
|
3
|
+
*
|
|
4
|
+
* Keyv-based storage utilities for Dynamic Client Registration.
|
|
5
|
+
* Follows @mcp-z/oauth pattern: single Keyv store with compound keys.
|
|
6
|
+
*
|
|
7
|
+
* Key Patterns:
|
|
8
|
+
* - dcr:client:{clientId} -> RegisteredClient
|
|
9
|
+
* - dcr:provider:{dcrToken} -> ProviderTokens
|
|
10
|
+
* - dcr:authcode:{code} -> AuthorizationCode
|
|
11
|
+
* - dcr:access:{token} -> AccessToken
|
|
12
|
+
* - dcr:refresh:{token} -> AccessToken
|
|
13
|
+
*/
|
|
14
|
+
import type { DcrClientInformation, DcrClientMetadata, ProviderTokens } from '@mcp-z/oauth';
|
|
15
|
+
import type { Keyv } from 'keyv';
|
|
16
|
+
import type { AccessToken, AuthorizationCode, RegisteredClient } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Register a new OAuth client (RFC 7591 Section 3.1)
|
|
19
|
+
*
|
|
20
|
+
* @param store - Keyv store for all DCR data
|
|
21
|
+
* @param metadata - Client registration metadata
|
|
22
|
+
* @returns Registered client with credentials
|
|
23
|
+
* @throws Error if validation fails
|
|
24
|
+
*/
|
|
25
|
+
export declare function registerClient(store: Keyv, metadata: DcrClientMetadata): Promise<DcrClientInformation>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a registered client by ID
|
|
28
|
+
*
|
|
29
|
+
* @param store - Keyv store for all DCR data
|
|
30
|
+
* @param clientId - Client identifier
|
|
31
|
+
* @returns Registered client or undefined if not found
|
|
32
|
+
*/
|
|
33
|
+
export declare function getClient(store: Keyv, clientId: string): Promise<RegisteredClient | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Validate client credentials
|
|
36
|
+
*
|
|
37
|
+
* @param store - Keyv store for all DCR data
|
|
38
|
+
* @param clientId - Client identifier
|
|
39
|
+
* @param clientSecret - Client secret
|
|
40
|
+
* @returns True if credentials are valid
|
|
41
|
+
*/
|
|
42
|
+
export declare function validateClient(store: Keyv, clientId: string, clientSecret: string): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Validate redirect URI for a client
|
|
45
|
+
*
|
|
46
|
+
* @param store - Keyv store for all DCR data
|
|
47
|
+
* @param clientId - Client identifier
|
|
48
|
+
* @param redirectUri - Redirect URI to validate
|
|
49
|
+
* @returns True if redirect URI is registered
|
|
50
|
+
*/
|
|
51
|
+
export declare function validateRedirectUri(store: Keyv, clientId: string, redirectUri: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* List all registered clients (for debugging)
|
|
54
|
+
*
|
|
55
|
+
* Note: This method uses Keyv's iterator which may not be available on all storage adapters.
|
|
56
|
+
* For production use, consider maintaining a separate index of client IDs.
|
|
57
|
+
*
|
|
58
|
+
* @param store - Keyv store for all DCR data
|
|
59
|
+
* @returns Array of all registered clients
|
|
60
|
+
*/
|
|
61
|
+
export declare function listClients(store: Keyv): Promise<RegisteredClient[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Delete a registered client
|
|
64
|
+
*
|
|
65
|
+
* @param store - Keyv store for all DCR data
|
|
66
|
+
* @param clientId - Client identifier
|
|
67
|
+
*/
|
|
68
|
+
export declare function deleteClient(store: Keyv, clientId: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Store provider tokens for a DCR access token
|
|
71
|
+
*
|
|
72
|
+
* @param store - Keyv store for all DCR data
|
|
73
|
+
* @param dcrToken - DCR-issued access token (used as key)
|
|
74
|
+
* @param tokens - Microsoft provider tokens (access, refresh, expiry)
|
|
75
|
+
*/
|
|
76
|
+
export declare function setProviderTokens(store: Keyv, dcrToken: string, tokens: ProviderTokens): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve provider tokens for a DCR access token
|
|
79
|
+
*
|
|
80
|
+
* @param store - Keyv store for all DCR data
|
|
81
|
+
* @param dcrToken - DCR-issued access token
|
|
82
|
+
* @returns Provider tokens or undefined if not found
|
|
83
|
+
*/
|
|
84
|
+
export declare function getProviderTokens(store: Keyv, dcrToken: string): Promise<ProviderTokens | undefined>;
|
|
85
|
+
/**
|
|
86
|
+
* Delete provider tokens for a DCR access token
|
|
87
|
+
*
|
|
88
|
+
* @param store - Keyv store for all DCR data
|
|
89
|
+
* @param dcrToken - DCR-issued access token
|
|
90
|
+
*/
|
|
91
|
+
export declare function deleteProviderTokens(store: Keyv, dcrToken: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Store an authorization code
|
|
94
|
+
*
|
|
95
|
+
* @param store - Keyv store for all DCR data
|
|
96
|
+
* @param code - Authorization code
|
|
97
|
+
* @param authCode - Authorization code data
|
|
98
|
+
*/
|
|
99
|
+
export declare function setAuthCode(store: Keyv, code: string, authCode: AuthorizationCode): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Get an authorization code
|
|
102
|
+
*
|
|
103
|
+
* @param store - Keyv store for all DCR data
|
|
104
|
+
* @param code - Authorization code
|
|
105
|
+
* @returns Authorization code data or undefined if not found
|
|
106
|
+
*/
|
|
107
|
+
export declare function getAuthCode(store: Keyv, code: string): Promise<AuthorizationCode | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete an authorization code
|
|
110
|
+
*
|
|
111
|
+
* @param store - Keyv store for all DCR data
|
|
112
|
+
* @param code - Authorization code
|
|
113
|
+
*/
|
|
114
|
+
export declare function deleteAuthCode(store: Keyv, code: string): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Store an access token
|
|
117
|
+
*
|
|
118
|
+
* @param store - Keyv store for all DCR data
|
|
119
|
+
* @param token - Access token
|
|
120
|
+
* @param tokenData - Access token data
|
|
121
|
+
*/
|
|
122
|
+
export declare function setAccessToken(store: Keyv, token: string, tokenData: AccessToken): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Get an access token
|
|
125
|
+
*
|
|
126
|
+
* @param store - Keyv store for all DCR data
|
|
127
|
+
* @param token - Access token
|
|
128
|
+
* @returns Access token data or undefined if not found
|
|
129
|
+
*/
|
|
130
|
+
export declare function getAccessToken(store: Keyv, token: string): Promise<AccessToken | undefined>;
|
|
131
|
+
/**
|
|
132
|
+
* Delete an access token
|
|
133
|
+
*
|
|
134
|
+
* @param store - Keyv store for all DCR data
|
|
135
|
+
* @param token - Access token
|
|
136
|
+
*/
|
|
137
|
+
export declare function deleteAccessToken(store: Keyv, token: string): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Store a refresh token
|
|
140
|
+
*
|
|
141
|
+
* @param store - Keyv store for all DCR data
|
|
142
|
+
* @param token - Refresh token
|
|
143
|
+
* @param tokenData - Access token data (contains refresh token context)
|
|
144
|
+
*/
|
|
145
|
+
export declare function setRefreshToken(store: Keyv, token: string, tokenData: AccessToken): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Get a refresh token
|
|
148
|
+
*
|
|
149
|
+
* @param store - Keyv store for all DCR data
|
|
150
|
+
* @param token - Refresh token
|
|
151
|
+
* @returns Access token data or undefined if not found
|
|
152
|
+
*/
|
|
153
|
+
export declare function getRefreshToken(store: Keyv, token: string): Promise<AccessToken | undefined>;
|
|
154
|
+
/**
|
|
155
|
+
* Delete a refresh token
|
|
156
|
+
*
|
|
157
|
+
* @param store - Keyv store for all DCR data
|
|
158
|
+
* @param token - Refresh token
|
|
159
|
+
*/
|
|
160
|
+
export declare function deleteRefreshToken(store: Keyv, token: string): Promise<void>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DCR Storage Utilities
|
|
3
|
+
*
|
|
4
|
+
* Keyv-based storage utilities for Dynamic Client Registration.
|
|
5
|
+
* Follows @mcp-z/oauth pattern: single Keyv store with compound keys.
|
|
6
|
+
*
|
|
7
|
+
* Key Patterns:
|
|
8
|
+
* - dcr:client:{clientId} -> RegisteredClient
|
|
9
|
+
* - dcr:provider:{dcrToken} -> ProviderTokens
|
|
10
|
+
* - dcr:authcode:{code} -> AuthorizationCode
|
|
11
|
+
* - dcr:access:{token} -> AccessToken
|
|
12
|
+
* - dcr:refresh:{token} -> AccessToken
|
|
13
|
+
*/
|
|
14
|
+
import type { DcrClientInformation, DcrClientMetadata, ProviderTokens } from '@mcp-z/oauth';
|
|
15
|
+
import type { Keyv } from 'keyv';
|
|
16
|
+
import type { AccessToken, AuthorizationCode, RegisteredClient } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Register a new OAuth client (RFC 7591 Section 3.1)
|
|
19
|
+
*
|
|
20
|
+
* @param store - Keyv store for all DCR data
|
|
21
|
+
* @param metadata - Client registration metadata
|
|
22
|
+
* @returns Registered client with credentials
|
|
23
|
+
* @throws Error if validation fails
|
|
24
|
+
*/
|
|
25
|
+
export declare function registerClient(store: Keyv, metadata: DcrClientMetadata): Promise<DcrClientInformation>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a registered client by ID
|
|
28
|
+
*
|
|
29
|
+
* @param store - Keyv store for all DCR data
|
|
30
|
+
* @param clientId - Client identifier
|
|
31
|
+
* @returns Registered client or undefined if not found
|
|
32
|
+
*/
|
|
33
|
+
export declare function getClient(store: Keyv, clientId: string): Promise<RegisteredClient | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Validate client credentials
|
|
36
|
+
*
|
|
37
|
+
* @param store - Keyv store for all DCR data
|
|
38
|
+
* @param clientId - Client identifier
|
|
39
|
+
* @param clientSecret - Client secret
|
|
40
|
+
* @returns True if credentials are valid
|
|
41
|
+
*/
|
|
42
|
+
export declare function validateClient(store: Keyv, clientId: string, clientSecret: string): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Validate redirect URI for a client
|
|
45
|
+
*
|
|
46
|
+
* @param store - Keyv store for all DCR data
|
|
47
|
+
* @param clientId - Client identifier
|
|
48
|
+
* @param redirectUri - Redirect URI to validate
|
|
49
|
+
* @returns True if redirect URI is registered
|
|
50
|
+
*/
|
|
51
|
+
export declare function validateRedirectUri(store: Keyv, clientId: string, redirectUri: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* List all registered clients (for debugging)
|
|
54
|
+
*
|
|
55
|
+
* Note: This method uses Keyv's iterator which may not be available on all storage adapters.
|
|
56
|
+
* For production use, consider maintaining a separate index of client IDs.
|
|
57
|
+
*
|
|
58
|
+
* @param store - Keyv store for all DCR data
|
|
59
|
+
* @returns Array of all registered clients
|
|
60
|
+
*/
|
|
61
|
+
export declare function listClients(store: Keyv): Promise<RegisteredClient[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Delete a registered client
|
|
64
|
+
*
|
|
65
|
+
* @param store - Keyv store for all DCR data
|
|
66
|
+
* @param clientId - Client identifier
|
|
67
|
+
*/
|
|
68
|
+
export declare function deleteClient(store: Keyv, clientId: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Store provider tokens for a DCR access token
|
|
71
|
+
*
|
|
72
|
+
* @param store - Keyv store for all DCR data
|
|
73
|
+
* @param dcrToken - DCR-issued access token (used as key)
|
|
74
|
+
* @param tokens - Microsoft provider tokens (access, refresh, expiry)
|
|
75
|
+
*/
|
|
76
|
+
export declare function setProviderTokens(store: Keyv, dcrToken: string, tokens: ProviderTokens): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve provider tokens for a DCR access token
|
|
79
|
+
*
|
|
80
|
+
* @param store - Keyv store for all DCR data
|
|
81
|
+
* @param dcrToken - DCR-issued access token
|
|
82
|
+
* @returns Provider tokens or undefined if not found
|
|
83
|
+
*/
|
|
84
|
+
export declare function getProviderTokens(store: Keyv, dcrToken: string): Promise<ProviderTokens | undefined>;
|
|
85
|
+
/**
|
|
86
|
+
* Delete provider tokens for a DCR access token
|
|
87
|
+
*
|
|
88
|
+
* @param store - Keyv store for all DCR data
|
|
89
|
+
* @param dcrToken - DCR-issued access token
|
|
90
|
+
*/
|
|
91
|
+
export declare function deleteProviderTokens(store: Keyv, dcrToken: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Store an authorization code
|
|
94
|
+
*
|
|
95
|
+
* @param store - Keyv store for all DCR data
|
|
96
|
+
* @param code - Authorization code
|
|
97
|
+
* @param authCode - Authorization code data
|
|
98
|
+
*/
|
|
99
|
+
export declare function setAuthCode(store: Keyv, code: string, authCode: AuthorizationCode): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Get an authorization code
|
|
102
|
+
*
|
|
103
|
+
* @param store - Keyv store for all DCR data
|
|
104
|
+
* @param code - Authorization code
|
|
105
|
+
* @returns Authorization code data or undefined if not found
|
|
106
|
+
*/
|
|
107
|
+
export declare function getAuthCode(store: Keyv, code: string): Promise<AuthorizationCode | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete an authorization code
|
|
110
|
+
*
|
|
111
|
+
* @param store - Keyv store for all DCR data
|
|
112
|
+
* @param code - Authorization code
|
|
113
|
+
*/
|
|
114
|
+
export declare function deleteAuthCode(store: Keyv, code: string): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Store an access token
|
|
117
|
+
*
|
|
118
|
+
* @param store - Keyv store for all DCR data
|
|
119
|
+
* @param token - Access token
|
|
120
|
+
* @param tokenData - Access token data
|
|
121
|
+
*/
|
|
122
|
+
export declare function setAccessToken(store: Keyv, token: string, tokenData: AccessToken): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Get an access token
|
|
125
|
+
*
|
|
126
|
+
* @param store - Keyv store for all DCR data
|
|
127
|
+
* @param token - Access token
|
|
128
|
+
* @returns Access token data or undefined if not found
|
|
129
|
+
*/
|
|
130
|
+
export declare function getAccessToken(store: Keyv, token: string): Promise<AccessToken | undefined>;
|
|
131
|
+
/**
|
|
132
|
+
* Delete an access token
|
|
133
|
+
*
|
|
134
|
+
* @param store - Keyv store for all DCR data
|
|
135
|
+
* @param token - Access token
|
|
136
|
+
*/
|
|
137
|
+
export declare function deleteAccessToken(store: Keyv, token: string): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Store a refresh token
|
|
140
|
+
*
|
|
141
|
+
* @param store - Keyv store for all DCR data
|
|
142
|
+
* @param token - Refresh token
|
|
143
|
+
* @param tokenData - Access token data (contains refresh token context)
|
|
144
|
+
*/
|
|
145
|
+
export declare function setRefreshToken(store: Keyv, token: string, tokenData: AccessToken): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Get a refresh token
|
|
148
|
+
*
|
|
149
|
+
* @param store - Keyv store for all DCR data
|
|
150
|
+
* @param token - Refresh token
|
|
151
|
+
* @returns Access token data or undefined if not found
|
|
152
|
+
*/
|
|
153
|
+
export declare function getRefreshToken(store: Keyv, token: string): Promise<AccessToken | undefined>;
|
|
154
|
+
/**
|
|
155
|
+
* Delete a refresh token
|
|
156
|
+
*
|
|
157
|
+
* @param store - Keyv store for all DCR data
|
|
158
|
+
* @param token - Refresh token
|
|
159
|
+
*/
|
|
160
|
+
export declare function deleteRefreshToken(store: Keyv, token: string): Promise<void>;
|