Module Webs_passkey.Challenge

Unique, expirable, challenges.

Validators

module Validator : sig ... end

Challenge validators.

Challenges

type t

The type for challenges.

val make : ?validity_s:int -> 'a Validator.t -> payload:'a -> t

make v ~payload is a new challenge valid for validity_s seconds with an associated stored payload payload stored in v.validity_s defaults to Validator.challenge_validity_s v.

val equal : t -> t -> bool

equal c0 c1 is true iff c0 and c0 are equal.

val compare : t -> t -> int

compare is a total order on challenges compatible with equal.

val validate : 'a Validator.t -> t -> ('a, unit) Stdlib.result

validate v c is Ok playload if c validates with v and Error () otherwise. payload is the value given to make. A challenge can be validated only once within the time slot it was given at make. Also due to Validator.max it may fail to validate earlier.

Converting

val to_binary_string : t -> string

to_binary_string c are the bytes of the challenge c.

val of_binary_string : string -> t

of_binary_string s is the challenge from the bytes in s.

Note. In practice challenges must be at least 16 bytes long. But the only thing you can do with a challenge is validate which will fail if that's not the case so we don't check anything here.

val pp : Stdlib.Format.formatter -> t -> unit

pp formats the bytes of the challenge as base64url.