Skip to content

Commit 7300682

Browse files
committed
[runtime] stabilize verify route closure and timeout expression
Why: /verify had a fragile inline timer/reason expression in the route block that needed an explicit, syntactically robust structure while preserving behavior and a single route close. Contract impact: none
1 parent 5859f64 commit 7300682

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,9 @@ for (const v of Object.keys(handlers)) {
15441544
}
15451545

15461546
app.post("/verify", async (req, res) => {
1547-
const timer = new Promise((_, rej) => setTimeout(() => rej(new Error("verify_timeout")), VERIFY_MAX_MS));
1547+
const timer = new Promise((_, rej) => {
1548+
setTimeout(() => rej(new Error("verify_timeout")), VERIFY_MAX_MS);
1549+
});
15481550
const runVerify = async () => {
15491551
const receipt = req.body;
15501552

@@ -1732,9 +1734,11 @@ app.post("/verify", async (req, res) => {
17321734

17331735
const okFinal = hashMatches === true && signatureValid === true && (wantSchema ? schemaOk === true : true);
17341736

1737+
const failureReason = sigErr || (wantSchema && !schemaOk ? "schema_invalid" : "verify_failed");
1738+
17351739
return res.json({
17361740
ok: okFinal,
1737-
...(okFinal ? {} : { reason: sigErr || (wantSchema && !schemaOk ? "schema_invalid" : "verify_failed") }),
1741+
...(okFinal ? {} : { reason: failureReason }),
17381742
signer_id: proof?.signer_id ?? null,
17391743
kid: proof?.kid ?? null,
17401744
hash_sha256: proof?.hash_sha256 ?? null,

0 commit comments

Comments
 (0)