session/cookie
src/session/cookie.tur
signing and verifying the session cookie's value.
Since: v0.1.0
defn
cookie-sign
(cookie-sign [signing-key : cstr id : cstr] :)
compute the cookie value to emit for a session ID.
Parameters
| signing-key | HMAC key, or "" to disable signing (borrowed) | |
| id | the session ID (borrowed) |
Returns
String -- owned cookie value.
Since: v0.2.0 (owned String return since v0.3.0)
defn
cookie-unsign
(cookie-unsign [signing-key : cstr value : cstr] :)
recover the session ID from a (possibly signed) value.
Parameters
| signing-key | HMAC key, or "" to disable verification (borrowed) | |
| value | the raw cookie value as received (borrowed) |
Returns
(Result String cstr) -- ok(id) with a fresh owned ID String (release it, or hand it to a consumer that takes ownership), or err(reason) -- a borrowed static reason -- on a missing/bad signature.
Since: v0.2.0 (owned String ok-value since v0.3.0)
Internal definitions
__empty?__cstr-dup__cstr-free__join-dot-- malloc'd "<a>.<b>".__last-dot-- index of the last '.' in s, or -1 if none.__substr-dup-- malloc'd copy of s[start..end); end < 0 means to the NUL.