()
| 32 | // network), plus a signer that mints tokens for it. Mirrors |
| 33 | // `mcp/mcp-auth.node.test.ts`. |
| 34 | const makeJwt = async () => { |
| 35 | const { publicKey, privateKey } = await generateKeyPair("RS256"); |
| 36 | const jwk = await exportJWK(publicKey); |
| 37 | const jwks = createLocalJWKSet({ keys: [{ ...jwk, kid: "test-key" }] }); |
| 38 | // Device-login tokens are verified by signature alone (client-scoped SSO |
| 39 | // JWKS); issuer/audience are not pinned. |
| 40 | const config: JwtBearerConfig = { jwks }; |
| 41 | const sign = (claims: Record<string, unknown>, expiration: string | number = "5m") => |
| 42 | new SignJWT(claims) |
| 43 | .setProtectedHeader({ alg: "RS256", kid: "test-key" }) |
| 44 | .setIssuer(issuer) |
| 45 | .setAudience(audience) |
| 46 | .setSubject("user_123") |
| 47 | .setIssuedAt() |
| 48 | .setExpirationTime(expiration) |
| 49 | .sign(privateKey); |
| 50 | return { config, sign }; |
| 51 | }; |
| 52 | |
| 53 | // The api-key path must never run for a JWT bearer, die loudly if it does. |
| 54 | const stubApiKeys = Layer.succeed(ApiKeyService)({ |
no outgoing calls
no test coverage detected