def head.check

bend-kit-jwt@0.11.0.1 · jwt.bend:307

import bend-kit-jwt@0.11.0.1/jwt.bend as Jwt
import Base

307# The header's alg is exactly the pinned one, and it asks for no extension: crit (RFC 7515 §4.1.11) and
308# b64 (RFC 7797) change how the token must be read, and neither is implemented.
309def head.check(+a: Alg, +h: List<&2, Field>) -> Result<&1, &1, Err, Unit>:
310  do Result<&1, &1, Err, Unit>:
311    got : String <- head.alg(field(h, "alg"))
312    u : Unit <- fail.if(Bool.not(String.eq(got, alg.name(a))), AlgMismatch{})
313    fail.if(Bool.or(has(h, "crit"), has(h, "b64")), Crit{})

Uses (16)

Used by (3)