Skip to content

Commit 5d61dd1

Browse files
committed
rename getAuthInfo to resolveAuthInfo for clarity and update references across exercises
1 parent da84e72 commit 5d61dd1

File tree

29 files changed

+627
-56
lines changed

29 files changed

+627
-56
lines changed

exercises/03.auth-info/01.problem.introspect/src/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { EPIC_ME_AUTH_SERVER_URL } from './client.ts'
88
// - scope: string (space-separated list of scopes)
99
// - sub: string (the user id)
1010

11-
// 🐨 export an async function called getAuthInfo that accepts the request
11+
// 🐨 export an async function called resolveAuthInfo that accepts the request
1212
// 🐨 if the request has an Authorization header, get the token from it
1313
// if it doesn't, return null
1414
// 🐨 construct a URL pointing to `/oauth/introspection` on the auth server

exercises/03.auth-info/01.problem.introspect/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { McpAgent } from 'agents/mcp'
88
import {
99
// 💰 you'll need this:
10-
// getAuthInfo,
10+
// resolveAuthInfo,
1111
handleOAuthAuthorizationServerRequest,
1212
handleOAuthProtectedResourceRequest,
1313
handleUnauthorized,

exercises/03.auth-info/01.solution.introspect/src/auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const introspectResponseSchema = z.object({
1010
sub: z.string(),
1111
})
1212

13-
export async function getAuthInfo(request: Request): Promise<AuthInfo | null> {
14-
const token = request.headers.get('authorization')?.replace(/^Bearer\s+/i, '')
13+
export async function resolveAuthInfo(
14+
authHeader: string | null,
15+
): Promise<AuthInfo | null> {
16+
const token = authHeader?.replace(/^Bearer\s+/i, '')
1517
if (!token) return null
1618

1719
const validateUrl = new URL(

exercises/03.auth-info/01.solution.introspect/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@modelcontextprotocol/sdk/types.js'
77
import { McpAgent } from 'agents/mcp'
88
import {
9-
getAuthInfo,
9+
resolveAuthInfo,
1010
handleOAuthAuthorizationServerRequest,
1111
handleOAuthProtectedResourceRequest,
1212
handleUnauthorized,
@@ -85,7 +85,9 @@ export default {
8585
}
8686

8787
if (url.pathname === '/mcp') {
88-
const authInfo = await getAuthInfo(request)
88+
const authInfo = await resolveAuthInfo(
89+
request.headers.get('authorization'),
90+
)
8991
if (!authInfo) return handleUnauthorized(request)
9092

9193
const mcp = EpicMeMCP.serve('/mcp', {

exercises/03.auth-info/02.problem.error/src/auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const introspectResponseSchema = z.object({
1010
sub: z.string(),
1111
})
1212

13-
export async function getAuthInfo(request: Request): Promise<AuthInfo | null> {
14-
const token = request.headers.get('authorization')?.replace(/^Bearer\s+/i, '')
13+
export async function resolveAuthInfo(
14+
authHeader: string | null,
15+
): Promise<AuthInfo | null> {
16+
const token = authHeader?.replace(/^Bearer\s+/i, '')
1517
if (!token) return null
1618

1719
const validateUrl = new URL(

exercises/03.auth-info/02.problem.error/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@modelcontextprotocol/sdk/types.js'
77
import { McpAgent } from 'agents/mcp'
88
import {
9-
getAuthInfo,
9+
resolveAuthInfo,
1010
handleOAuthAuthorizationServerRequest,
1111
handleOAuthProtectedResourceRequest,
1212
handleUnauthorized,
@@ -85,7 +85,9 @@ export default {
8585
}
8686

8787
if (url.pathname === '/mcp') {
88-
const authInfo = await getAuthInfo(request)
88+
const authInfo = await resolveAuthInfo(
89+
request.headers.get('authorization'),
90+
)
8991
if (!authInfo) return handleUnauthorized(request)
9092

9193
const mcp = EpicMeMCP.serve('/mcp', {

exercises/03.auth-info/02.solution.error/src/auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ const introspectResponseSchema = z.object({
1010
sub: z.string(),
1111
})
1212

13-
export async function getAuthInfo(request: Request): Promise<AuthInfo | null> {
14-
const token = request.headers.get('authorization')?.replace(/^Bearer\s+/i, '')
13+
export async function resolveAuthInfo(
14+
authHeader: string | null,
15+
): Promise<AuthInfo | null> {
16+
const token = authHeader?.replace(/^Bearer\s+/i, '')
1517
if (!token) return null
1618

1719
const validateUrl = new URL(

exercises/03.auth-info/02.solution.error/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@modelcontextprotocol/sdk/types.js'
77
import { McpAgent } from 'agents/mcp'
88
import {
9-
getAuthInfo,
9+
resolveAuthInfo,
1010
handleOAuthAuthorizationServerRequest,
1111
handleOAuthProtectedResourceRequest,
1212
handleUnauthorized,
@@ -85,7 +85,9 @@ export default {
8585
}
8686

8787
if (url.pathname === '/mcp') {
88-
const authInfo = await getAuthInfo(request)
88+
const authInfo = await resolveAuthInfo(
89+
request.headers.get('authorization'),
90+
)
8991
if (!authInfo) return handleUnauthorized(request)
9092

9193
const mcp = EpicMeMCP.serve('/mcp', {

exercises/03.auth-info/03.problem.active/src/auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ const introspectResponseSchema = z.object({
1212
sub: z.string(),
1313
})
1414

15-
export async function getAuthInfo(request: Request): Promise<AuthInfo | null> {
16-
const token = request.headers.get('authorization')?.replace(/^Bearer\s+/i, '')
15+
export async function resolveAuthInfo(
16+
authHeader: string | null,
17+
): Promise<AuthInfo | null> {
18+
const token = authHeader?.replace(/^Bearer\s+/i, '')
1719
if (!token) return null
1820

1921
const validateUrl = new URL(

exercises/03.auth-info/03.problem.active/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@modelcontextprotocol/sdk/types.js'
77
import { McpAgent } from 'agents/mcp'
88
import {
9-
getAuthInfo,
9+
resolveAuthInfo,
1010
handleOAuthAuthorizationServerRequest,
1111
handleOAuthProtectedResourceRequest,
1212
handleUnauthorized,
@@ -85,7 +85,9 @@ export default {
8585
}
8686

8787
if (url.pathname === '/mcp') {
88-
const authInfo = await getAuthInfo(request)
88+
const authInfo = await resolveAuthInfo(
89+
request.headers.get('authorization'),
90+
)
8991
if (!authInfo) return handleUnauthorized(request)
9092

9193
const mcp = EpicMeMCP.serve('/mcp', {

0 commit comments

Comments
 (0)