pure.bend checks
raw source on the hub · import bend-kit-webhooks@0.15.0.1/pure.bend as Pure
Pure webhook headers, timestamps, and signature framing.
3 imports
import Base import bend-kit-time@0.3.0.3/pure.bend as Time import bend-kit-int@0.2.0.0/int.bend as Int
Types
type Err source · line 6 · raw
Data
Missing@name:String -> Err
BadSecretErr
BadIdErr
BadTimestampErr
TooOldErr
TooNewErr
NoMatchErr
CryptoErr@code:U32 -> @msg:String -> Err
Definitions
def field.head source · line 18 · raw
@xs:List<&2, String> -> Maybe<&2, String>
def field.of source · line 25 · raw
@r:Pair(Map<&2, List<&2, String>>, List<&2, String>) -> Maybe<&2, String>
def field source · line 29 · raw
@+h:Map<&2, List<&2, String>> -> @k:String -> Maybe<&2, String>
def need source · line 32 · raw
@+name:String -> @m:Maybe<&2, String> -> Result<&1, &1, Err, String>
def strip source · line 40 · raw
@+p:String -> @+s:String -> Maybe<&2, String>
s after the prefix p, or None.
def push source · line 43 · raw
@m:Maybe<&2, String> -> @rest:List<&2, String> -> List<&2, String>
def put source · line 50 · raw
@m:Map<&2, List<&2, String>> -> @k:String -> @v:String -> Map<&2, List<&2, String>>
def digits source · line 53 · raw
@s:String -> Bool
def ts.some source · line 60 · raw
@ok:Bool -> @m:Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.I64> -> Result<&1, &1, Err, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.I64>
def ts.read source · line 72 · raw
@+s:String -> Result<&1, &1, Err, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.I64>
Unix seconds: 1 to 18 ASCII digits, no sign, so the parse never overflows.
def window.pick source · line 76 · raw
@old:Bool -> @ahead:Bool -> Result<&1, &1, Err, Unit>
def window source · line 84 · raw
@+tol:U32 -> @now:0xf6004ed2773adf12acc8863c4d424242/pure.Instant -> @t:0x4eed9d7ac6ece61523d747a9d804e4f0/int.I64 -> Result<&1, &1, Err, Unit>
t within tol seconds of now, either way.
def id.check source · line 92 · raw
@+id:String -> Result<&1, &1, Err, Unit>
A webhook id is not empty and has no '.', so id.timestamp.body reads one way.
def pad source · line 96 · raw
@+s:String -> String
'=' up to a multiple of four chars.
def std.sigs source · line 101 · raw
@xs:List<&2, String> -> List<&2, String>
The v1 entries of a space-separated webhook-signature; other versions are skipped.
def std.check source · line 108 · raw
@+tol:U32 -> @now:0xf6004ed2773adf12acc8863c4d424242/pure.Instant -> @+h:Map<&2, List<&2, String>> -> Result<&1, &1, Err, Pair(String, Pair(String, List<&2, String>))>
def sign.check source · line 118 · raw
@+id:String -> @+ts:0x4eed9d7ac6ece61523d747a9d804e4f0/int.I64 -> Result<&1, &1, Err, Pair(String, String)>
def stripe.t source · line 124 · raw
@s:String -> @r:Pair(List<&2, String>, List<&2, String>) -> Pair(List<&2, String>, List<&2, String>)
def stripe.v.push source · line 128 · raw
@s:String -> @r:Pair(List<&2, String>, List<&2, String>) -> Pair(List<&2, String>, List<&2, String>)
def stripe.v source · line 132 · raw
@m:Maybe<&2, String> -> @r:Pair(List<&2, String>, List<&2, String>) -> Pair(List<&2, String>, List<&2, String>)
def stripe.item source · line 139 · raw
@t:Maybe<&2, String> -> @v:Maybe<&2, String> -> @r:Pair(List<&2, String>, List<&2, String>) -> Pair(List<&2, String>, List<&2, String>)
def stripe.items source · line 148 · raw
@xs:List<&2, String> -> Pair(List<&2, String>, List<&2, String>)
The t= and v1= values of comma-separated items; other schemes (v0) are skipped.
def stripe.single source · line 155 · raw
@ts:List<&2, String> -> @vs:List<&2, String> -> Result<&1, &1, Err, Pair(String, List<&2, String>)>
def stripe.one source · line 165 · raw
@r:Pair(List<&2, String>, List<&2, String>) -> Result<&1, &1, Err, Pair(String, List<&2, String>)>
Exactly one t=: a second one would leave the signed timestamp ambiguous.
def stripe.when source · line 169 · raw
@+tol:U32 -> @now:0xf6004ed2773adf12acc8863c4d424242/pure.Instant -> @p:Pair(String, List<&2, String>) -> Result<&1, &1, Err, Pair(Unit, Pair(String, List<&2, String>))>
def stripe.check source · line 176 · raw
@+tol:U32 -> @now:0xf6004ed2773adf12acc8863c4d424242/pure.Instant -> @+h:Map<&2, List<&2, String>> -> Result<&1, &1, Err, Pair(Unit, Pair(String, List<&2, String>))>
def github.check source · line 182 · raw
@+h:Map<&2, List<&2, String>> -> Result<&1, &1, Err, Pair(Unit, Pair(String, List<&2, String>))>