|
1 | 1 | import fastify, { FastifyInstance } from "fastify"; |
2 | | -import { getSharedTestPublicJWK } from "./shared-test-keys"; |
| 2 | +import * as jose from "jose"; |
| 3 | +import { getSharedTestKeyPair, getSharedTestPublicJWK } from "./shared-test-keys"; |
3 | 4 |
|
4 | 5 | // In-memory store for registered eVaults |
5 | 6 | const registeredEVaults = new Map<string, { uri: string; evault: string }>(); |
@@ -69,13 +70,21 @@ export async function createMockRegistryServer(port: number = 4322): Promise<Fas |
69 | 70 | return reply.status(400).send({ error: "Missing platform parameter" }); |
70 | 71 | } |
71 | 72 |
|
72 | | - // Return a mock JWT token for the platform |
73 | | - // In a real scenario, this would be a proper JWT signed by the registry |
74 | | - const mockToken = `mock.jwt.token.${platform}.${Date.now()}`; |
| 73 | + // Generate a proper JWT token signed with the shared test key pair |
| 74 | + // This token can be verified by vault-access-guard using the JWKS endpoint |
| 75 | + const { privateKey } = await getSharedTestKeyPair(); |
| 76 | + const now = Date.now(); |
| 77 | + const expiresAt = now + 3600000; // 1 hour from now |
| 78 | + |
| 79 | + const token = await new jose.SignJWT({ platform }) |
| 80 | + .setProtectedHeader({ alg: "ES256", kid: "entropy-key-1" }) |
| 81 | + .setIssuedAt(Math.floor(now / 1000)) |
| 82 | + .setExpirationTime(Math.floor(expiresAt / 1000)) |
| 83 | + .sign(privateKey); |
75 | 84 |
|
76 | 85 | return reply.status(200).send({ |
77 | | - token: mockToken, |
78 | | - expiresAt: Date.now() + 3600000, // 1 hour from now |
| 86 | + token, |
| 87 | + expiresAt, |
79 | 88 | }); |
80 | 89 | }); |
81 | 90 |
|
|
0 commit comments