norbix_webhooks library

Inbound Norbix webhook receiver.

Handle webhook deliveries (trigger → destination POST) at your HTTP endpoint. This is the subscriber side — distinct from the Hub webhooks resource, which configures destinations.

import 'package:norbix/norbix_webhooks.dart';

final receiver = NorbixWebhookReceiver(); // reads env

receiver.on<UserDto>(NorbixWebhookEvents.membershipUserRegistered, (user, event) {
  print(user.email ?? user.userName);
});

receiver.onAll(kNorbixWebhookEventNames, (envelope, ctx) => log(envelope.event));

final result = await receiver.handle(rawBody: body, headers: headers);

Classes

DeliveryHeaders
Parsed Norbix delivery headers from an inbound request.
FileDeleted
files.file.deleted payload.
FileResourceRef
A file reference carried by files.file.uploaded.
Mutation<T>
A before/after pair for a mutation event (user.updated, record.updated).
NorbixErrorItem
One error inside the gateway's responseStatus.errors list.
NorbixWebhookEvents
Named event constants — use these instead of raw strings.
NorbixWebhookHeaders
Outbound Norbix webhook delivery header names (gateway WebhookDeliveryClient).
NorbixWebhookReceiver
Inbound Norbix webhook receiver.
Normalized
The payload + metadata produced from a raw envelope.
SignatureCheck
Result of a signature check.
UserDto
A membership user. Email / username are optional (username-only signup).
UserInvited
membership.user.invited payload (no full entity yet).
WebhookContext
Context passed to onAll handlers alongside the envelope.
WebhookEntityRef
A single entity id reference.
WebhookEnvelope
The raw JSON envelope POSTed to a destination.
WebhookEvent
Metadata object passed as the 2nd argument to a typed handler.
WebhookEventMetadata
Identifiers lifted off the wire payload onto WebhookEvent.metadata.
WebhookHandleResult
Result of handling a delivery (respond 200 to the caller).
WebhookRecordIds
Batch record ids.
WebhookSchemaInfo
Schema identifiers for database.* events.

Constants

kNorbixWebhookEventNames → const List<String>
Closed catalog of event names a destination may subscribe to.

Functions

computeSignature(String secret, String timestamp, String rawBody) String
sha256=<hex> HMAC-SHA256 of "<timestamp>.<rawBody>".
norbixBodySaysItFailed(Object? body) bool
true when the body carries responseStatus.isSuccess == false.
normalizeWebhook(WebhookEnvelope envelope) Normalized
Turn a raw envelope into (payload, metadata).
parseWebhookHeaders(Map<String, String> headers) DeliveryHeaders
Read Norbix delivery headers from an inbound request (case-insensitive).
verifySignature({required String secret, required String rawBody, String? signature, String? timestamp, int toleranceSeconds = 300}) SignatureCheck
Verify X-Norbix-Signature against the raw body.

Typedefs

NorbixWebhookHandler<T> = FutureOr<void> Function(T payload, WebhookEvent event)
A typed handler: receives the normalised payload and event metadata.
NorbixWebhookRawHandler = FutureOr<void> Function(WebhookEnvelope envelope, WebhookContext ctx)
A raw handler: receives the envelope and delivery context.

Exceptions / Errors

NorbixAuthError
401 / 403 — invalid or missing credentials.
NorbixClientError
4xx other than 401/403/404/429.
NorbixError
Base exception thrown by every Norbix call.
NorbixNotFoundError
404 — resource does not exist.
NorbixRateLimitError
429 — rate limited. Retry-After (seconds) is in details when present.
NorbixServerError
5xx — server-side failure.
NorbixTransportError
Network or timeout failure (no HTTP status).
NorbixWebhookError
Base error for inbound webhook handling.
NorbixWebhookParseError
The delivery body was not a valid webhook envelope (respond HTTP 400).
NorbixWebhookSignatureError
The delivery signature could not be verified (respond HTTP 401).