MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeJwt

Function makeJwt

apps/cloud/src/api/protected-jwt-auth.node.test.ts:34–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32// network), plus a signer that mints tokens for it. Mirrors
33// `mcp/mcp-auth.node.test.ts`.
34const 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.
54const stubApiKeys = Layer.succeed(ApiKeyService)({

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected