( effect: Effect.Effect<A, McpJwtVerificationError>, )
| 70 | error.reason === "expired" || error.reason === "invalid"; |
| 71 | |
| 72 | const withJwtVerificationSpan = <A>( |
| 73 | effect: Effect.Effect<A, McpJwtVerificationError>, |
| 74 | ): Effect.Effect<A, McpJwtVerificationError> => |
| 75 | effect.pipe( |
| 76 | Effect.result, |
| 77 | Effect.flatMap((outcome) => |
| 78 | Effect.gen(function* () { |
| 79 | if (Result.isSuccess(outcome)) { |
| 80 | yield* Effect.annotateCurrentSpan({ "mcp.auth.jwt_verify.outcome": "verified" }); |
| 81 | return outcome; |
| 82 | } |
| 83 | |
| 84 | yield* Effect.annotateCurrentSpan({ |
| 85 | "mcp.auth.jwt_verify.outcome": outcome.failure.reason, |
| 86 | }); |
| 87 | |
| 88 | return isExpectedJwtVerificationError(outcome.failure) |
| 89 | ? outcome |
| 90 | : yield* Effect.fail(outcome.failure); |
| 91 | }), |
| 92 | ), |
| 93 | Effect.withSpan("mcp.auth.jwt_verify"), |
| 94 | Effect.flatMap((outcome) => |
| 95 | Result.isSuccess(outcome) ? Effect.succeed(outcome.success) : Effect.fail(outcome.failure), |
| 96 | ), |
| 97 | ); |
| 98 | |
| 99 | export const verifyMcpAccessToken = ( |
| 100 | token: string, |
nothing calls this directly
no test coverage detected