(
token: string,
jwks: JWTVerifyGetKey,
options: {
readonly issuer: string;
readonly audience: string;
},
)
| 80 | ); |
| 81 | |
| 82 | export const verifyMcpAccessToken = ( |
| 83 | token: string, |
| 84 | jwks: JWTVerifyGetKey, |
| 85 | options: { |
| 86 | readonly issuer: string; |
| 87 | readonly audience: string; |
| 88 | }, |
| 89 | ) => |
| 90 | Effect.gen(function* () { |
| 91 | const { payload } = yield* Effect.tryPromise({ |
| 92 | try: () => |
| 93 | jwtVerify(token, jwks, { |
| 94 | issuer: options.issuer, |
| 95 | audience: options.audience, |
| 96 | }), |
| 97 | catch: classifyJwtVerificationError, |
| 98 | }).pipe(withJwtVerificationSpan); |
| 99 | |
| 100 | if (!payload.sub) return null; |
| 101 | |
| 102 | return { |
| 103 | accountId: payload.sub, |
| 104 | organizationId: (payload.org_id as string | undefined) ?? null, |
| 105 | } satisfies VerifiedToken; |
| 106 | }); |
| 107 | |
| 108 | export const verifyWorkOSMcpAccessToken = ( |
| 109 | token: string, |
no outgoing calls
no test coverage detected