def key

bend-kit-webhooks@0.11.0.1 · webhooks.bend:143

import bend-kit-webhooks@0.11.0.1/webhooks.bend as Webhooks
import Base
import bend-kit-encoding@0.5.0.0/encoding.bend as Enc
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

143# std: a Standard Webhooks secret. Otherwise the secret's UTF-8 is the key, as Stripe and GitHub use it.
144def key(+std: Bool, +s: String) -> Maybe<&1, Bytes.Bytes>:
145  match std:
146    case True{}:
147      key.std(s)
148    case False{}:
149      nonempty(Some{Enc.utf8.encode(s)})

Uses (7)

Used by (1)