From fc56dc9151cb303fbaa85374a0ca8f9b4fc551b8 Mon Sep 17 00:00:00 2001 From: Matthias Tan Date: Tue, 21 Oct 2025 15:04:07 +0100 Subject: [PATCH] up --- examples/prompt/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/prompt/index.js b/examples/prompt/index.js index 6a7a738..48b8828 100644 --- a/examples/prompt/index.js +++ b/examples/prompt/index.js @@ -10,6 +10,9 @@ import { // Define the port to listen on const PORT = 3000; +// Cache for verification keys to improve performance +let verificationKeysCache = { id: "", keys: [] }; + // Define the handler function async function handler(request, response) { console.log(`Received [${request.method}] to [${request.url}]`); @@ -36,15 +39,18 @@ async function handler(request, response) { const keyID = String(request.headers["github-public-key-identifier"]); try { - const { isValidRequest, payload } = await verifyAndParseRequest( + const { isValidRequest, payload, cache } = await verifyAndParseRequest( body, signature, keyID, { token: tokenForUser, + cache: verificationKeysCache, }, ); + verificationKeysCache = cache; + if (!isValidRequest) { console.error("Request verification failed"); response.writeHead(401, { "Content-Type": "text/plain" });