(cause: unknown)
| 49 | const isJoseErrorCode = (code: string): boolean => code.startsWith("ERR_J"); |
| 50 | |
| 51 | const classifyJwtVerificationError = (cause: unknown): McpJwtVerificationError => |
| 52 | new McpJwtVerificationError({ |
| 53 | cause, |
| 54 | reason: (() => { |
| 55 | const code = getJoseErrorCode(cause); |
| 56 | if (code === JWTExpired.code) return "expired"; |
| 57 | if ( |
| 58 | code === JWKSTimeout.code || |
| 59 | code === JWKSInvalid.code || |
| 60 | code === null || |
| 61 | !isJoseErrorCode(code) |
| 62 | ) { |
| 63 | return "system"; |
| 64 | } |
| 65 | return "invalid"; |
| 66 | })(), |
| 67 | }); |
| 68 | |
| 69 | const isExpectedJwtVerificationError = (error: McpJwtVerificationError): boolean => |
| 70 | error.reason === "expired" || error.reason === "invalid"; |
nothing calls this directly
no test coverage detected