73 std::function<std::int64_t()>
now;
93 explicit operator bool() const noexcept {
return ok; }
118Result verify(
const std::string& secret,
const std::string& signature_header,
Base class for every error the SDK raises. Never carries raw token material.
Definition errors.hpp:12
Wraps secret material (access tokens, mTLS private keys).
Definition sensitive.hpp:26
Thrown by verify_or_throw() when a delivery does not verify.
Definition webhook.hpp:98
VerifyError error() const noexcept
Definition webhook.hpp:102
VerifyException(VerifyError error, const std::string &message)
Definition webhook.hpp:100
Event verify_or_throw(const Sensitive< std::string > &secret, const std::string &signature_header, const std::string &body, const Options &options=Options{})
Throwing twin of verify(), for handlers that prefer an exception.
VerifyError
Why verification failed.
Definition webhook.hpp:37
@ kMalformedTimestamp
t= was not a non-negative decimal integer
@ kTimestampOutOfTolerance
|now - t| exceeded the freshness window
@ kMalformedHeader
unparseable, empty, or no/duplicate t=
@ kTimestampHeaderMismatch
X-Axiam-Timestamp disagreed with t=
@ kMissingSignature
header parsed but carried no v1= value
@ kSignatureMismatch
no supplied v1 matched the computed MAC
@ kEmptySecret
no secret configured — fail closed, never skip
const char * to_string(VerifyError error) noexcept
Stable, secret-free description of a VerifyError.
Result verify(const Sensitive< std::string > &secret, const std::string &signature_header, const std::string &body, const Options &options=Options{})
Verify a webhook delivery.
Definition authenticator.hpp:40
A verified delivery.
Definition webhook.hpp:52
std::int64_t timestamp
The t= value covered by the MAC.
Definition webhook.hpp:54
std::string delivery_id
X-Axiam-Delivery, when supplied to verify() via Options.
Definition webhook.hpp:59
std::string event_type
X-Axiam-Event, when supplied to verify() via Options.
Definition webhook.hpp:56
std::string body
The raw body that was verified.
Definition webhook.hpp:61
Optional inputs to verify().
Definition webhook.hpp:65
std::chrono::seconds tolerance
Two-sided freshness window.
Definition webhook.hpp:69
std::string event_type
X-Axiam-Event, copied into the returned Event. Not covered by the MAC.
Definition webhook.hpp:81
std::string delivery_id
X-Axiam-Delivery, copied into the returned Event. Not covered by the MAC.
Definition webhook.hpp:84
std::optional< std::string > timestamp_header
The separate X-Axiam-Timestamp header, if the receiver read it.
Definition webhook.hpp:78
std::function< std::int64_t()> now
Time source in unix seconds.
Definition webhook.hpp:73
Outcome of verify(). Contextually convertible to bool; falsy means rejected.
Definition webhook.hpp:88
Event event
Definition webhook.hpp:91
const char * error_message() const noexcept
Definition webhook.hpp:94
VerifyError error
Definition webhook.hpp:90
bool ok
Definition webhook.hpp:89